我正在尝试为 IOS 6 添加 UIRefreshControl。
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshView:)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;
}
和
if (NSClassFromString(@"UIRefreshControl") != Nil) {
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshView:)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;
}
但得到错误
dyld: Symbol not found: _OBJC_CLASS_$_UIRefreshControl
Referenced from: /Users/office/Library/Application Support/iPhone Simulator/4.3.2/Applications/DD532E42-77F9-471C-AA48-7F9EAE9268C6/Verizon.app/Verizon
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/i PhoneSimulator4.3.sdk/System/Library/Frameworks/UIKit.framework/UIKit
我正在使用 IOS 6 SDK 并在 iPhone 4.3 模拟器上运行。
当我删除代码时
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshView:)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;
一切都适用于 iPhone 4.3 模拟器。有趣的代码里面
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { }
在 iPhone 4.3 模拟器上永远不会被调用,不知道为什么会出错。请帮忙!!