Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2030337
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: LINUX

2009-05-27 10:47:17

Mail list: http://groups.google.com/group/iphone-dev
  1. A typical iPhone application has only one window, an application changes its content by changing the content views displayed in that window.
  2. Safari's Bookmarks
    The Safari's bookmarks is located at ~/Library/Safari/Bookmarks.plist, the format of that file is "Apple Property List". The property list can be in binary format, and text format, you can use tool 'plutil' to convert the file between binary and text formts.
    The date in Bookmarks.plist:
    1. Get date string
    2. Convert string to NSTimeInterval (float)\
    3. Then call [NSDate dateWithTimeIntervalSinceReferenceDate:timeInterval] to convert date to NSDate
  3.  Add Tool Bar Programmtically
    1. Create instance of UITooBar, suppoes it is toolBar, then sent tool bar style, size
    2. Create instances UIBarButtonItem, suppose they are item1, item2, item3;
    3. Create array like:
      NSArray itemsArray = [NSArray arrayWithObjects:item1, item2, item3, nil];
    4. Add items to tool bar
      [toolBar setItems:itemsArray animated:YES];
    5. Add tool bar to current view
      [[self view] addSubView:toolBar];
  4.  How to Create View Controller Being Contained in Nib File
    Sometimes, you add view controller into your Nib file, but how to create this type ofcontroller:
    1. Customize View Controller
      @interface MyViewController : UIViewController
      {
          IBOutlet UIViewController *controller;
      }
      @property (nonatomic,retain) IBOutlet UIViewController *controller;
      @end

      @implementation MyViewController
      @syntherize controller
      @end
    2. Create Connections
      Create following connections:
      1. View controller object embedded in Interface Builder to outlet
        "controller" of class MyViewController;
      2. View object embedded in Interface Builder to outlet "view" of class MyViewController.
    3. Create Instance of View Controller
      MyViewController *aViewController = [[MyViewController alloc]
      initWithNibName:@"MyNibFile" bundle:[NSBundle mainBundle]];
      [window addSubView:aViewController.view];
    4. ...
  5. Add "x" At The Right of UITextField
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
  6. You can add view and/or view controller in Nib, then load the Nib file into application, or you can customize them by implementing sub-class of UIView/UIViewController.
  7. When you create a iPhone project via XCode, it generates some files, about the porpuse of those files, please refer to tutorial "Beginning iPhone Developer: Exploring the iPhone SDK" ch3 "Handling Basic Interaction".
  8. About UIScrollView
    1. Issue: Views added into UIScrollView is not shown
      Solution: These views has been added to other views, but any view can't be sub-view of more than one views; so before adding those view to UIScrollView, please remove them from their previous views by calling removeFroSuperview.
    2. Issue: ScrollView can't be scrolled
      Solution: set contentSize of UISCrollView
    3. Don't call UIScrollView.scrollRectToVisible in it's delegate, otherwise, application will dead-lock during scrolling.
    4. ...
  9. Replace internal interface of class
    Class klass = objc_getClass("UIWebDocumentView");
    if( klass == nil )
        return;         // if there is no UIWebDocumentView in the future.
        
    // replace touch began event
    method_exchangeImplementations(class_getInstanceMethod(klass,@selector(touchesBegan:withEvent:)),class_getInstanceMethod(klass, @selector(__replacedTouchesBegan:withEvent:)) );
  10. Sample: UICWebView
  11. UITableView
    1. If you want to add multiple controls into one table cell, you must define subclass of UITableViewCell, and add the controls as subview of customized UITableViewCell
    2. If you want to devide table view into multple section, and each section are grouped, you must set UITableView's Stype to 'Grouped', and implement UITableViewDelegate's function 'numberOfSections'
    3. If you want to set icon bedise table cell, you must implement UITableViewDelegate's function - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
      i.e: please refer to sample application UICatalog
    4. ....
  12. Extrace resources from application (X86)
  13. Run-time error "EXC_BAD_ACCESS"
    Invalid memory accessing, such as to access released memory (Refer to object after invoked release mothod)
  14. Safe browser sample
    SafeEyes, Smart Surfin
  15. Enumator/Simulator path under Mac OS X
    ~/Library/Application Support/iPhoneSimulator/User/
  16. How to get event when application terminate in UIView sub-class
    1, Define a callback
    - (void) applicationWillTerminate:(NSNotifiation *)notification
    2, Register observer
    UIApplication *app = [UIApplication sharedApplication];
    [[NSNotificationCenter defaultCenter] addObserver:self seletor:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app];
  17. How to customize control
    Illustrate use UIViewController
    • Create a new class CustomViewControl derived from UIViewController
    • Add view controller in Nib
    • When view controller in Nib get focus, press Command-4 to bring up identity inspector, then change the class of table view controller to CustomViewControl
    • Now, when you init frame with that nib file, the instance of CustomViewControl will be created.
  18. String format
    %@  String   ie. [[NSString alloc] initwithFormat:@"The name is %@", @"Jimmy"];
  19. Play system audio
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileUrlWithPath :xxxx], &soundID);
    AudioServicesPlaySystemSound(soundID);
    Before building, press menu Project > Add to Project... to add AudioToolBox.FrameWork under /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulatore2.1.sdk/System/Library/Frameworks/ to your project.
  20. Outlets and Actions
    • Defien outlets in .h file
      IBOutlet UIButton *myButton;

      The IBOutlet keyword is defined like this:
      #ifndef IBOutlet
      #define IBOutlet
      #endif
      IBOutlet doesn absolutely nothins, it sole purpose is to act as a hint to tell Interface Builder that this is an interface variable that we are connect to an object in a nib file must be proceded by the IBOutlet keyword.
    • Define action method
      - (IBAction) doSomethins:(id)sender;
  21. Communicating Asynchronously
    //Register notification observer
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getData:) name:NSFileHandleReadCompletionNotification object:portHandle];

    //Send message to read data asynchronously
    [portHandle readInBackgroundAndNotify]; //portHande is a *NSFileHandle;


  22. ...
阅读(3627) | 评论(0) | 转发(0) |
0

上一篇:Webkit Development

下一篇:[iPode] iPode Usage

给主人留下些什么吧!~~