1、设置自定义Delegate的时候,应该在相应的.h文件Import,而不是在.m文件中。
2、比如UIButton被按下时,要调用一个方法,不管这个UIButton是在xib中添加还是说在代码中创建。所调用的方法必须包含(id)sender 这样这个参数,不然会出现指针错误。
3、当一个在UINavigation Controller使用pushView开启一个带有UIWebView的界面,在该viewDidload中UIWebView加载URL,按下back键返回先前的界面,再次开启UIWebView界面,此时UIWebView在完成新URL加载之前,将显示上次加载的内容。为了解决这个问题,可以在viewWillDisappear方法中加入如下语句:
[webView stringByEvaluatingJavaScriptFromString:@"document.open();document.close()"];
4、presentModalViewController
最好在主线程中调用,在delegate中有时无响应!!
5、@synthesize 和 @dynamic 的区别:
@dynamic
You use the
@dynamic
keyword to tell the compiler that you will fulfill the API contract implied by a property either by providing method implementations directly or at runtime using other mechanisms such as dynamic loading of code or dynamic method resolution.