2014年5月25日 星期日
2014年1月23日 星期四
2014年1月15日 星期三
2013年12月28日 星期六
2013年12月20日 星期五
2013年12月11日 星期三
2013年11月25日 星期一
2013年11月22日 星期五
2013年11月20日 星期三
2013年7月6日 星期六
2013年7月3日 星期三
2013年6月29日 星期六
2013年2月7日 星期四
2012年6月4日 星期一
[iOS] Redirect to App store
http://stackoverflow.com/questions/5638563/link-to-app-store-with-no-redirects
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/us/app/easygroup-full/id513988942"]]
2012年3月11日 星期日
[iOS] UIAlertView
UIAlert View with multiple options.
in .h: include UIAlertViewDelegate
in .m: implement delegate for UIAlertViewDelegate
in .h: include UIAlertViewDelegate
@interface MyController : UIViewController <UIAlertViewDelegate> {
}
in .m: implement delegate for UIAlertViewDelegate
#pragma UIAlertView
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"%d", buttonIndex);
[iOS] UIActionSheet
UIActionSheet Class Reference
Move Cancel Button from top to bottom
In .h: include UIAlertViewDelegate
In .m: implement delegates
Move Cancel Button from top to bottom
In .h: include UIAlertViewDelegate
@interface MyController : UIViewController <UIAlertViewDelegate> {
}
In .m: implement delegates
- (void) ShowActionSheet:(NSString *)title {
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:title
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles: nil];
[actionSheet addButtonWithTitle:@"Option 1"];
[actionSheet addButtonWithTitle:@"Option 2"];
[actionSheet addButtonWithTitle:@"Option 3"];
[actionSheet addButtonWithTitle:@"Cancel"];
actionSheet.cancelButtonIndex = actionSheet.numberOfButtons;
[actionSheet showInView:self.view];
[actionSheet release];
}
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"title=%@, buttonIndex: %d, cancelButtonIndex: %d, firstOtherButtonIndex: %d",
actionSheet.title,
buttonIndex,
actionSheet.cancelButtonIndex,
actionSheet.firstOtherButtonIndex);
}
2012年2月17日 星期五
[iOS] Class 1: NSArray, NSMutableArray, NSDictionary, NSMutableDictionary
NSArray
Add an empty object
Retrieve NSArray
NSMutableArray
1. Similar to NSArray.
2. Contents of array can be modified. (add, remove and sort)
Create NSMutableArray
Add an object (append to the end of the bookList)
Insert an object at an specific place "index".
Remove an object at "index".
Sort Array: in alphabetical order
NSDictionary
1. Cannot be modified. (add, remove and sort)
Create NSDictionary
Retrieve Object
NSMutableDictionary
1. Can be modified. (add, remove and sort)
Create NSMutableDictionary
Add an object
2. Contents of array cannot be modified. (add, remove and sort)
Create NSArray
NSArray *bookList = [NSArray arrayWithObjects: @"iPhone4", @"iOS", @"MacX", nil];Add an empty object
[NSNull null]Retrieve NSArray
NSArray *bookList = [NSArray arrayWithObjects:@"Moby", @"Frank", @"Tom", nil];
for (int y=0; y < bookList.count, y++) {
NSLog (@"Book Title is %@", [bookList objectAtIndex:y])
}
result:
Book Title is Moby
Book Title is Frank
Book Title is TomNSMutableArray
1. Similar to NSArray.
2. Contents of array can be modified. (add, remove and sort)
Create NSMutableArray
NSMutableArray *bookList = [NSArray arrayWithObjects:@"iPhone4", @"iOS", @"MacX", nil];
Add an object (append to the end of the bookList)
[bookList addObject:@"New book"];
Insert an object at an specific place "index".
[bookList insertObject:@"New book" atIndex:index];
Remove an object at "index".
[bookList removeObject:index];
Sort Array: in alphabetical order
[bookList sortUsingSelector:@selector(caseInsensitiveCompare:)];
NSDictionary
1. Cannot be modified. (add, remove and sort)
Create NSDictionary
NSDictionary *book = [NSDictionary dictionaryWithObjectsAndKeys:
@"a", @"1",
@"b", @"2",
@"c", @"3",
@"d", @"4",
@"e", @"5",
nil];
Retrieve Object
[book objectForKey: @"1"];
NSMutableDictionary
1. Can be modified. (add, remove and sort)
Create NSMutableDictionary
NSMutableDictionary *book = [NSDictionary dictionaryWithObjectsAndKeys:
@"a", @"1",
@"b", @"2",
@"c", @"3",
@"d", @"4",
@"e", @"5",
nil];
Add an object
[book setObject: @"Value" forKey: @"KeyIndex"];
訂閱:
文章 (Atom)

