iOS 编程陷井.

作者:不及格的程序员-八神

    •  要注意不支持的特性

    比如你的手持设备不支持发送短信或邮件的话,创建该类型的类时将返回nil...,这与我们平常习惯性的理解不同,如果是我设计我会让它抛出异常可能会更好,至少不需要查api文档就知道怎么回事。

    •  设备的方向

    当你在window上连续添加两个景色模式的视图控制器的时候,第二个视图的方向会保持人像模式,并且它的shouldAutorrotateToInterfaceOrientation方法不会被触发...

    •  根视图中的输出口

   这个算不算,可以根据开发人员的个人理解而定,按传统编程想法,当从nib文件实例化一个视图控制器时,我觉得视图中的所有输出口控件都会自动初始化,但是苹果的模式不是,它需要激发根视图view属性,确认将下面的所有子视图连接到输出口上.

    •  在烦忙的工作开始之前,先播放动画

   这又是一个苹果模式,如果你想在下载文件的时候同时播放等待动画,如果你先去执行(注意是直接执行而不是延时执行)下载代码,那么前面的动画将在烦忙的代码执行完毕后播放,显然不是我们要的.

[activityIndicator startAnimating];
[self performSelector:@selector(someMethod) withObject:nil afterDelay:0.0];


这是苹果关于屏幕旋转问题的答QA,里面也说了window仅支持第一个视图的旋转....
Technical Q&A QA1688 Why won't my UIViewController rotate with the device? Q: Why won't my UIViewController rotate with the device? A: Why won't my UIViewController rotate with the device? There can be several possible reasons your view controller does not rotate. The UIViewController class provides the fundamental view-management model for iPhone applications. It provides automatic support for rotating the views of the view controller in response to changes to the orientation of the device. If the autoresizing properties of your view and subviews are properly configured, this behavior is essentially free. Your view controller may not rotate in certain situations if: The view controller does not implement this delegate method: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; Even if shouldAutorotateToInterfaceOrientation is implemented, you should make sure it returns YES for all the orientations you wish to support. To support all orientations, simply always return YES. The view controller's UIView property is embedded inside UIWindow but alongside an additional view controller. You may find a situation where shouldAutorotateToInterfaceOrientation is called once at startup for a given view controller but is never called again when the device is rotated. Because view controllers are tightly bound to the views they manage, they are also part of the responder chain used to handle events. View controllers are themselves descendants of the UIResponder class and are inserted into the responder chain between the managed view and its superview. So it is common practice to have one primary view controller in your application as part of the responder chain. You would typically add one primary view controller such as a UINavigationController, UITabBarController or a generic UIViewController to your UIWindow. For example, this is done by calling: [myWindow addSubview:primaryViewController.view]; If you add an additional view controller's UIView property to UIWindow (at the same level as your primary view controller) via the following: [myWindow addSubview:anotherController.view]; this additional view controller will not receive rotation events and will never rotate. Only the first view controller added to UIWindow will rotate. Note: You may add one view controller's UIView property as a subview to another view controller. In doing so, both views will rotate but the parent view controller remains in charge of determining the supported orientations via its shouldAutorotateToInterfaceOrientation method. Note: Keep in mind that UINavigationController and UITabBarController have the capability to manage a "stack" or "list" of view controllers on their own. You have added your view controller's UIView property to UIWindow as a subview, but prematurely released it soon after. UIWindow will retain that view, but not the view controller itself. You must not release it prematurely. Declare it as a "retainable" property in your UIApplicationDelegate subclass. Note: UINavigationController and UITabBarController retain your view controllers, so you can release them once they have been added. All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set. To make sure that all your child view controllers rotate correctly, you must implement shouldAutorotateToInterfaceOrientation for each view controller representing each tab or navigation level. Each must agree on the same orientation for that rotate to occur. That is, they all should return YES for the same orientation positions. Overriding the -(id)init: or -(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle method without calling super. For the object to be initialized properly, you must call super on any init or initWithNibName method you are overriding for your view controllers.


 

自定义表格中的uiimageview与button图片的延迟显示问题,button没有问题。

但uiimageview显示会出现问题,如果你在本地文件,显示成功率会大,如果是网上的图片,就不会显示了。

2013-06-25日找到原因:自定义属性self.imageView 与系统属性同名了,改个名子 就都正常了。。。。。

[self setNeedsLayout] 导致了最后面的图片视图,在异步加载完成时,跑来了最前面,就是说它的z-index改变了,结果会把其它的标签视图挡住。。。
#import "InfoListTableCell.h"
#import "InfoListEntity.h"


@implementation InfoListTableCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

-(void)updateCellContent:(id)obj
{    
    InfoListEntity *entity = (InfoListEntity*)obj;
    self.ownEntity = entity;
    self.labTitle.text = entity.title;
    [entity.imageURL getCacheDataDir:@"cacheDir" completionHandler:^(NSData *data, NSError *error)
    {
        //dispatch_async(dispatch_get_main_queue(), ^
        //{
            self.imageView.image = [UIImage imageWithData:data];
            [self setNeedsLayout]; 如果是网上下载,这句非常重要,有本地缓存就不需要,为什么?
        //});
    }];

 

 

转载于:https://www.cnblogs.com/ioriwellings/archive/2011/05/25/2056376.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值