// .h
@property (strong, nonatomic) IBOutlet UIImageView *logoImageView;
// .m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Answer to a stackoverflow question. |
查找应用程序的主窗口对象。一般情况就是 UIWindow
。
当然一个应用程序可以有多个 window
,键盘是一个 window
[[UIApplication sharedApplication] keyWindow]
就是查找当前应用程序的主 window。
via :here
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL) containsChinese:(NSString *)str { | |
for(int i = 0; i < [str length]; i++) { | |
int a = [str characterAtIndex:i]; | |
if( a > 0x4e00 && a < 0x9fff) | |
return TRUE; | |
} | |
return FALSE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event | |
{ | |
if (motion == UIEventSubtypeMotionShake) | |
{ | |
NSLog(@"shaked"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
NSDate *currentDate = [NSDate date]; | |
NSLog(@"Current Date: %@", currentDate); | |
// Outputs current day of week as a string in locale dependent on current regional settings. | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setDateFormat:@"EEEE"]; | |
NSLog(@"The day of the week: %@", [dateFormatter stringFromDate:[NSDate date]]); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.h | |
#import <UIKit/UIKit.h> | |
@interface UIColor (RandomColor) | |
+(UIColor *) randomColor; | |
@end | |
//.m |
if you don't want to mess up your current dev environment, you can just run:
$ /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
Alternatively:
sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer
then you can do one of these two:
xcrun swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AFNetworkReachabilityManager.h> | |
#import <MBProgressHUD.h> | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
// Override point for customization after application launch. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/Library/MobileDevice/Provisioning\ Profiles |
OlderNewer