讓View自動適應(yīng)屏幕高度:
- (void) suiteForDeviceScreen
{
    self.frame = [UIScreen mainScreen].applicationFrame;

    self.frame = CGRectMake(self.frame.origin.x, y, self.frame.size.width, self.frame.size.height);  //self.originY = 0;

}
參考這篇文章:http://www.2cto.com/kf/201305/207632.html
為避免鏈接丟失,我復(fù)制重點(diǎn)內(nèi)容:
先從viewController的view說起吧(以下代碼全部為ARC環(huán)境下)手動創(chuàng)建view都是從loadView方法中初始化viewController的self.view,這里說API中的屬性:

1、[UIScreen mainScreen].bounds,屏幕的bounds,

2、[UIScreen mainScreen].applicationFrame,app的frame,當(dāng)app的statusBar隱藏時,它跟[UIScreen mainScreen].bounds實(shí)際是一樣的

 我一般這么創(chuàng)建view:self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

此時view的frame在iPhone5是0,20,320,548,之前的iPhone是0,20,320,460,

之后viewController的self.view的frame會自動在viewWillAppear方法中重新變化,自動適配屏幕的尺寸,也就是說,如果你有navigationBar,那么此時view的frame是0,20,320,504(iPhone5),我在以前都是手動在loadView的時候減44的,不知道有沒有跟我一樣的。。。

加載網(wǎng)絡(luò)圖片
//這個函數(shù)的內(nèi)部API已經(jīng)做了圖片的緩存,不需要再額外緩存圖片


+(void)addPicture:(NSString*)imageUrlPath to:(UIImageView*)addTo withSize:(CGRect)withSize{

    UIImageView *imageView = [[UIImageView alloc] init];

    

    NSURL *activityImageURL = [NSURL URLWithString:imageUrlPath];

    

    [imageView setImageWithURL:activityImageURL placeholderImage:nil];

    [imageView setContentMode:UIViewContentModeScaleToFill];

    imageView.frame = withSize;

    

    [addTo addSubview:imageView];

}


字符串格式的時間轉(zhuǎn)換為NSDate類型:
+(NSDate*)myStringToDate:(NSString *)str{
    //@"2013-08-13 20:28:40";  //傳入時間
    NSDateFormatter *format = [[NSDateFormatter alloc] init];
    [format setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [format dateFromString:str];
    return date;
}
改變鍵盤的“換行”內(nèi)容為“完成”,并隱藏鍵盤:
//設(shè)置鍵盤,使換行變?yōu)橥瓿勺謽?/span>
    _inputedPlace.keyboardType = UIKeyboardAppearanceDefault;
    _inputedPlace.returnKeyType = UIReturnKeyDone;
    [[self.inputedPlace rac_signalForControlEvents:UIControlEventEditingDidEndOnExit]
     subscribeNext:^(id x) {
         [self.inputedPlace resignFirstResponder];
     }];

.