語言為內建注音的話
- []=「」
- \=、
- shift + 1=!
- shift + , =,
- shift + . = 。
- shift + ?=?
- shift + []=『』
- shift + ; = :
- option + ; =;
持續增加
#pragma mark -
線段分類 |
#pragma mark - test
以test為分類的標題 |
#pragma mark - test - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; UIButton *btnDownLoad = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btnDownLoad setTitle:@"test" forState:UIControlStateNormal]; [btnDownLoad addTarget:self action:@selector(testDL) forControlEvents:UIControlEventTouchUpInside]; btnDownLoad.frame = CGRectMake(100, 100, 100, 100); [self.view addSubview:btnDownLoad]; // Do any additional setup after loading the view. } //FIXME:fix - (void) testDL { NSURL *url = [NSURL URLWithString:@"http://funwish.net/jhaoheng/testDL.rtf"]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0]; connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; connection = nil; } //TODO:todo - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { filesize = [NSNumber numberWithUnsignedInteger:[response expectedContentLength]]; } //???:?????? //!!!:!!!!!!!!!!!! - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)recievedData { if (data==nil) { data = [[NSMutableData alloc] initWithCapacity:2048]; } [data appendData:recievedData]; //NSNumber *resourceLength = [NSNumber numberWithUnsignedInteger:[data length]]; //MAGIC //float progress = [resourceLength floatValue] / [filesize floatValue]; //progressLine.progress = progress; }
其它相關 |
Improvements:A "Search" filter has been added to the Files tabImproved autocompletion for HTML, CSS, Javascript, and PHPThe path bar is now truncated to your local / remote root pathPort, User, and IdentityFile in ~/.ssh/config are now parsed for SFTP connectionsOption+Return will now open files in the active tab/split via keyboardAdded Japanese localizationAdded a LESS mode. (If you installed a third-party mode, you might wish to delete it.)
Significantly improved stability on Mac OS X 10.6Hopefully improved the reliability of iCloudImproved the reliability of AirPreviewImproved private key reliability for SFTP connectionsWeb preview more reliably catches external CSS changesPHP rendering will no longer break after saving in some circumstancesFixed an issue where the location of the document cannot be determinedFixed an exception when attempting to clone a Git repositoryFixed issues with code foldingNow possible again to add/edit a search URL for a custom bookNo auto-mark for publishing after ejecting siteSave As no longer also saves to FTP in some circumstancesGit push/pull buttons are no longer gone after a commitFixed a Git error when trying to clone a site to a non-existent directoryCheckout to Revision now works more reliably for GitCode validation improved when collapsedImproved nested Javascript syntax coloringNew Tab and New Split subitems now have unique names so shortcuts can be assignedSSH key selector button now shows hidden filesThe connect button in Sharing is now activeClips can no longer lock up when moving them into a groupRight-clicking in icon view no longer clears the selectionJavascript hints now function properlyUsing the keyboard to navigate through tabs now properly scrolls the tabsWorked around mod_sftp server issue where permissions would be set to 000 when openingFixed a situation where named placeholders could not be named properlyThe mysterious iCloud panel is now disabled on Mac OS X 10.8SCM operations now update the publishing queue"Refresh" menu item and keyboard shortcut now works in SQL viewCMD-F now properly focuses filter boxesViewing page source while previewing in iPad/iPhone frames now renders correctlyThe Color pop is now shown for "border-color"Dragging a remote file tab is now more usefulSCM operations when offline no longer create a string of errorsInvisible files now show up in Find Files resultsThe "Port" is now saved properly in SQL site configurationsCustom book images no longer get stretched in the toolbar iconFixed an issue where the Clips editor window could appear far offscreenFixed various crashes, exceptions, and annoyances!
圖1 |
圖二 |
圖三 |
圖四 |
[目前的頁面 presentModalViewController:將要跳轉的頁面 animated:YES];
[self dismissModalViewControllerAnimated:YES];//切換過的畫面,跳回上一層畫面相關使用方法,請參閱其他資源。
#import <UIKit/UIKit.h> @interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> @end
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults]; NSArray* languages = [defs objectForKey:@"AppleLanguages"]; NSString* preferredLang = [languages objectAtIndex:0]; NSLog(@"%@",preferredLang); /* for (int i=0; i國際設定->語言->語言列表array...[0][1][2][3][4] General -> international -> Language -> language list , array[0][1][2][3][4] */
NSLog(@"this : %@",[[UIDevice currentDevice] model]); //獲取目前使用的設備 NSLog(@"%@",[[UIDevice currentDevice] name]); // Name of the phone as named by user NSLog(@"%@",[[UIDevice currentDevice] uniqueIdentifier]); // A GUID like string NSLog(@"%@",[[UIDevice currentDevice] systemName]); // "iPhone OS" NSLog(@"%@",[[UIDevice currentDevice] systemVersion]); // "2.2.1" NSLog(@"%@",[[UIDevice currentDevice] model]); // "iPhone" on both devices NSLog(@"%@",[[UIDevice currentDevice] localizedModel]); // "iPhone" on both devices
// // UIDevice.h // UIKit // // Copyright (c) 2007-2011, Apple Inc. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKitDefines.h> typedef enum { UIDeviceOrientationUnknown, UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left UIDeviceOrientationFaceUp, // Device oriented flat, face up UIDeviceOrientationFaceDown // Device oriented flat, face down } UIDeviceOrientation; typedef enum { UIDeviceBatteryStateUnknown, UIDeviceBatteryStateUnplugged, // on battery, discharging UIDeviceBatteryStateCharging, // plugged in, less than 100% UIDeviceBatteryStateFull, // plugged in, at 100% } UIDeviceBatteryState; // available in iPhone 3.0 typedef enum { #if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED UIUserInterfaceIdiomPhone, // iPhone and iPod touch style UI UIUserInterfaceIdiomPad, // iPad style UI #endif } UIUserInterfaceIdiom; /* The UI_USER_INTERFACE_IDIOM() macro is provided for use when deploying to a version of the iOS less than 3.2. If the earliest version of iPhone/iOS that you will be deploying for is 3.2 or greater, you may use -[UIDevice userInterfaceIdiom] directly. */ #define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone) #define UIDeviceOrientationIsPortrait(orientation) ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown) #define UIDeviceOrientationIsLandscape(orientation) ((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight) UIKIT_CLASS_AVAILABLE(2_0) @interface UIDevice : NSObject { @private NSInteger _numDeviceOrientationObservers; float _batteryLevel; struct { unsigned int batteryMonitoringEnabled:1; unsigned int proximityMonitoringEnabled:1; unsigned int expectsFaceContactInLandscape:1; unsigned int orientation:3; unsigned int batteryState:2; unsigned int proximityState:1; } _deviceFlags; } (UIDevice *)currentDevice; @property(nonatomic,readonly,retain) NSString *name; // e.g. "My iPhone" @property(nonatomic,readonly,retain) NSString *model; // e.g. @"iPhone", @"iPod touch" @property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model @property(nonatomic,readonly,retain) NSString *systemName; // e.g. @"iOS" @property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @"4.0" @property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated. @property(nonatomic,readonly,retain) NSString *uniqueIdentifier __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA,__MAC_NA,__IPHONE_2_0,__IPHONE_5_0); // a string unique to each device based on various hardware info. @property(nonatomic,readonly,getter=isGeneratingDeviceOrientationNotifications) BOOL generatesDeviceOrientationNotifications; - (void)beginGeneratingDeviceOrientationNotifications; // nestable - (void)endGeneratingDeviceOrientationNotifications; @property(nonatomic,getter=isBatteryMonitoringEnabled) BOOL batteryMonitoringEnabled __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // default is NO @property(nonatomic,readonly) UIDeviceBatteryState batteryState __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // UIDeviceBatteryStateUnknown if monitoring disabled @property(nonatomic,readonly) float batteryLevel __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown @property(nonatomic,getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // default is NO @property(nonatomic,readonly) BOOL proximityState __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); // always returns NO if no proximity detector @property(nonatomic,readonly,getter=isMultitaskingSupported) BOOL multitaskingSupported __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); @property(nonatomic,readonly) UIUserInterfaceIdiom userInterfaceIdiom __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2); - (void)playInputClick __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_2); // Plays a click only if an enabling input view is on-screen and user has enabled input clicks. @end @protocol UIInputViewAudioFeedback <NSObject> @optional @property (nonatomic, readonly) BOOL enableInputClicksWhenVisible; // If YES, an input view will enable playInputClick. @end UIKIT_EXTERN NSString *const UIDeviceOrientationDidChangeNotification; UIKIT_EXTERN NSString *const UIDeviceBatteryStateDidChangeNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); UIKIT_EXTERN NSString *const UIDeviceBatteryLevelDidChangeNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); UIKIT_EXTERN NSString *const UIDeviceProximityStateDidChangeNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
#import "sys/utsname.h"//記得加入此行 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { // iOS 5 code //代碼範例使用的是navigation中更改背景圖的方法,ios4以前使用的方法很多種,但蘋果希望目前使用這種方法,故以前的某些方法會被禁用 [self.navigationController.navigationBar setBackgroundImage:[UIImageimageNamed:@"top_bk.png"] forBarMetrics:UIBarMetricsDefault]; } else { // iOS 4.x code }
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone) { UIViewController* IPhoneViewController1=[[UIViewController alloc]init]; self.window.rootViewController= IPhoneViewController1; } else if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad) { UIViewController* IPadViewController1=[[UIViewController alloc]init]; self.window.rootViewController= IPadViewController1; }
[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
#import <UIKit/UIKit.h> @protocol passValueDelegate -(void)passString:(NSString *)value; @end
view1 |
view2 |
view1 |
//設定類型 [[UIApplication shareApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; //特定透明 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES]; //隱藏狀態列 [[UIApplication shareApplication] setStatusBarHidden:YES];
此圖為網路截取 |
UIView *v1 = [[UIView alloc] initWithFrame:CGRectMake(101.0f, 100.0f, 51.0f, 50.0f)]; v1.backgroundColor = [UIColor yellowColor]; NSLog(@"frame_x : %f, frame_y : %f",v1.frame.origin.x,v1.frame.origin.y); NSLog(@"frane_w : %f, frame_h : %f",v1.frame.size.width,v1.frame.size.height); NSLog(@"bounds_x : %f,bounds_y : %f",v1.bounds.origin.x,v1.bounds.origin.y); NSLog(@"bounds_w : %f,bounds_h : %f",v1.bounds.size.width,v1.bounds.size.height); [self.view addSubview:v1];
2012-06-11 10:09:33.064 TAAZA[489:f803] frame_x : 101.000000, frame_y : 100.000000 2012-06-11 10:09:33.065 TAAZA[489:f803] frane_w : 51.000000, frame_h : 50.000000 2012-06-11 10:09:33.065 TAAZA[489:f803] bounds_x : 0.000000,bounds_y : 0.000000 2012-06-11 10:09:33.066 TAAZA[489:f803] bounds_w : 51.000000,bounds_h : 50.000000
#import <AVFoundation/AVFoundation.h>
#import <QuartzCore/QuartzCore.h>引用的protocol有以下兩個
<UITabBarDelegate,UITabBarControllerDelegate> <UITextViewDelegate>
// // view2.m // sound & tts // // Created by jhaoheng on 2012/6/1. // Copyright (c) 2012年 __n11_studio__. All rights reserved. // #import "view2.h" //由於本範例有使用到 Layer 類別的方法,所以必須先匯入其對應的標頭檔和 Framework。 #import <QuartzCore/QuartzCore.h> @implementation view2 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization //self.title = @"three"; UIImage *img_speak = [UIImage imageNamed:@"google.png"]; UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"G_TTS" image:img_speak tag:1]; self.tabBarItem = item3; /* The item’s image. If nil, an image is not displayed. The images displayed on the tab bar are derived from this image. If this image is too large to fit on the tab bar, it is scaled to fit. The size of an tab bar image is typically 30 x 30 points. The alpha values in the source image are used to create the unselected and selected images—opaque values are ignored. */ /* if you want to create icons for iPhone UITabBar ,you can read this website http://steveweller.com/articles/toolbar-icons/ */ } return self; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle /* // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { } */ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; input_text = [[UITextView alloc]initWithFrame:CGRectMake(10, 10, 300, 150)]; input_text.font = [UIFont fontWithName:@"Arial" size:20]; input_text.textColor = [UIColor whiteColor]; input_text.delegate = self; input_text.backgroundColor = [UIColor whiteColor]; input_text.text = @"you can type something in this frame and click the speaker button to pronounce"; input_text.returnKeyType = UIReturnKeyDefault; input_text.keyboardType = UIKeyboardTypeDefault; /* autocapitalizationType — 首字大寫 autocorrectionType — 自動更正錯字 enablesReturnKeyAutomatically — 確認使用者有輸入文字後才啟用return鍵 keyboardAppearance — 鍵盤外型 keyboardType — 鍵盤種類 returnKeyType — return鍵的類型 secureTextEntry — 隱藏輸入的文字 */ //設定是否可捲動 input_text.scrollEnabled = YES; //自適應高度 //text.autoresizingMask = UIViewAutoresizingFlexibleHeight; //設定橘色背景與棕色邊框 [input_text setBackgroundColor:[UIColor orangeColor]]; [[input_text layer] setBorderColor:[[UIColor brownColor] CGColor]]; //邊框粗細 [[input_text layer] setBorderWidth:1.5]; //設定圓角程度 [[input_text layer] setCornerRadius:20]; /*指定內文字體大小並置中 [text setFont:[UIFont boldSystemFontOfSize:50.0]]; [text setTextAlignment:UITextAlignmentCenter]; */ //設定無法再被編輯 [input_text setEditable:YES]; //使內文保持在UITextView邊框之內 [input_text setClipsToBounds: YES]; [self.view addSubview:input_text]; UIButton *speaker = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [speaker setTitle:@"speaker" forState:UIControlStateNormal]; [speaker setTitle:@"connect" forState:UIControlStateHighlighted]; speaker.frame = CGRectMake(20, 295, 280, 40); [speaker addTarget:self action:@selector(machine_speak) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:speaker]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark -uibutton -(void)machine_speak { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"file.mp3"]; NSString *urlString; if ([input_text.text canBeConvertedToEncoding: NSASCIIStringEncoding]) {//如果是英語 urlString = [NSString stringWithFormat:@"http://www.translate.google.com/translate_tts?tl=en&q=%@",input_text.text]; } else { //如果是非英語 urlString = [NSString stringWithFormat:@"http://www.translate.google.com/translate_tts?tl=zh-TW&q=%@",input_text.text]; } NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" forHTTPHeaderField:@"User-Agent"]; NSURLResponse* response = nil; NSError* error = nil; NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; [data writeToFile:path atomically:YES]; NSError *err; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&err]; player.volume = 0.8f; [player prepareToPlay]; [player setNumberOfLoops:0]; [player play]; } } #pragma mark - UITextView Delegate Methods -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)closetext { if ([closetext isEqualToString:@"\n"]) { [input_text resignFirstResponder]; return NO; } return YES; } @end