我有2个xib.
我想要2个不同的UIButton指向同一个IBOutlet对象.我怎么能管理呢?我也有UIImageView和UILabel这个问题.
谢谢
这是我的代码:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *nonNumberSet = [[NSCharacterSet characterSetWithCharactersInString:@"??????????????????????????"] invertedSet];
// max charcters
NSUInteger newLength = [textField.text length] + [string length] - range.length;
if (newLength > 14)
return NO;
// allow backspace
if (range.length > 0 && [string length] == 0) {
return YES;
}
// do not allow . at the beggining
if (range.location == 0 && [string isEqualToString:@"."]) {
return NO;
}
if ((range.location > 0) && (([[textField.text substringWithRange:NSMakeRange((range.location -1), 1)] isEqualToString:@"?"]) || ([[textField.text …Run Code Online (Sandbox Code Playgroud) 我从这篇文章得到了这个代码,一切都没问题,除了一件事,我有这个错误,我不知道如何解决.这是代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[[event touchesForView:self] anyObject] locationInView:self];
CGRect currentBounds = self.bounds;
CGFloat x = touchPoint.x - CGRectGetMidX(currentBounds);
if(x<0 && self.currentPage>=0){
self.currentPage--;
[self.delegate pageControlPageDidChange:self];
}
else if(x>0 && self.currentPage<self.numberOfPages-1){
self.currentPage++;
[self.delegate pageControlPageDidChange:self];
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
No visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'.
Run Code Online (Sandbox Code Playgroud)
我试图用ARC运行这段代码,我删除了dealloc方法,在这里改为赋值为weak:
@property (nonatomic, weak) NSObject<PageControlDelegate> *delegate;
Run Code Online (Sandbox Code Playgroud)
正如有人在答案中写道,但它仍然无效.
请帮我.
所以,我正在使用Xcode 4.2.1为iOS创建一个应用程序,我不知道为什么我的所有图标都很模糊,它们处于高清晰度,但由于某种原因,它们看起来很模糊,质量很差.
即使背景图片看起来很糟糕..
请帮帮我,我该怎么办呢?
这是原始按钮图像:

这是它在应用程序上的外观:

我有一个网页,让我们以StackOverflow为例.每个框都是这样的:

所以我的问题是,我怎么能设法做到,当有人用英文写出消息的标题时,它会像在图像中一样从左到右显示消息,当他从右到左书写时,它会显示它像这个:

它只会自动改变这个盒子的风格.如果它的LTR使用boxEnglish.css css为这个特定的框,如果它的RTL,使用boxHebrew.css作为特定框.也许我可以让用户选择RTL或LTR?
谢谢!
我有NSMutableArray70个对象,它们NSMutableDictionary在每个字典中我有2个值:"distance"和"indexPath".我想NSMutableArray从小距离到最大距离进行排序.使用我粘贴的代码后,距离以KM为单位,数组看起来像这样:
NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"distance" ascending:YES];
[branchDistance sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];
Run Code Online (Sandbox Code Playgroud)
这是这种方法的结果:
(lldb) po [branchDistance objectAtIndex:0]
(id) $1 = 0x0d6ac240 {
"<NSIndexPath 0xd6cf180> 1 indexes [0]" = indexPath;
"8.078547" = distance;
}
(lldb) po [branchDistance objectAtIndex:1]
(id) $2 = 0x0d6a64a0 {
"<NSIndexPath 0xd6cf3b0> 1 indexes [1]" = indexPath;
"45.044069" = distance;
}
(lldb) po [bran(lldb) po [branchDistance objectAtIndex:2]
(id) $4 = 0x0d6cf550 {
"<NSIndexPath 0xd69b3f0> 1 indexes [2]" = indexPath;
"9.992081" = distance;
}
(lldb) …Run Code Online (Sandbox Code Playgroud) objective-c nsdictionary nsmutablearray nssortdescriptor ios
是否可以Home Screen从我的应用程序内部以编程方式截取屏幕截图?

谢谢!
我一直在使用旧的Facebook SDK并保存了accessToken和expirationDate里面的NSUserDefaults.但是现在在新版本中Facebook SDK 3.2有一个叫做的新类FBAccessTokenData,我可以通过以下方式从那里获取accessToken:
[FBSession activeSession].accessTokenData.accessToken
[FBSession activeSession].accessTokenData.expirationDate
Run Code Online (Sandbox Code Playgroud)
我的问题是当我重新启动我的应用程序并再次单击Facebook按钮时,它会去Facebook寻求新的令牌,尽管我在3分钟前使用该应用程序,登录Facebook并获得新令牌.因此令牌尚未保存.
我想保存新的accessToken进入[FBSession activeSession],但accessToken并expirationDate是只读属性.
我现在几次阅读Facebook SDK文档,搜索stackOverflow和网络,但仍然没有任何线索如何做到这一点.
这是我的代码:
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
switch (state)
{
case FBSessionStateOpen:
{
// This is how i'm trying to save the token, like the old Facebook SDK.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[FBSession activeSession].accessTokenData.accessToken forKey:@"FBAccessTokenKey"];
[defaults setObject:[FBSession activeSession].accessTokenData.expirationDate forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSLog(@"FB: Session …Run Code Online (Sandbox Code Playgroud) 我有一个问题,无法映射json的嵌套对象.问题在于"容量"键.
这是错误:
restkit.object_mapping:RKMappingOperation.m:830 Did not find mappable relationship value keyPath 'capacities'
Run Code Online (Sandbox Code Playgroud)
我知道问题在于映射本身,但是无法想象:
RKObjectMapping *capacityMapping = [RKObjectMapping mappingForClass:[Capacity class]];
[capacityMapping addAttributeMappingsFromDictionary:@{ @"capacityText" : @"capacityText",
@"priceDescriptionText" : @"priceDescriptionText",
@"priceText" : @"priceText" }];
RKObjectMapping *colorsMapping = [RKObjectMapping mappingForClass:[Colors class]];
[colorsMapping addAttributeMappingsFromDictionary:@{ @"ID" : @"idNum",
@"Name" : @"name",
@"colorHex" : @"colorHex",
@"imageUrl" : @"imageURL" }];
RKObjectMapping *deviceDataMapping = [RKObjectMapping mappingForClass:[DeviceData class]];
[deviceDataMapping addAttributeMappingsFromDictionary:@{ @"device.ID" : @"idNum",
@"device.Name" : @"name",
@"device.additionalFeatures" : @"additionalFeatures",
@"device.deviceName" : @"deviceName",
@"device.mainFeatures" : @"mainFeatures",
@"device.supportPagesLinks" : @"supportPagesLinks",
@"device.whatsInTheKit" : @"whatsInTheKit" …Run Code Online (Sandbox Code Playgroud) 我有一个UIScrollView,在这个里面我有一个,在UIScrollView我UIView里面UIView有一些UITextField's,一些UILabel's,在底部有一个UITableView。
我想要UITableView适合它的内容高度,UIView适合它的内容高度,UIScrollView适合它的内容高度。
在UITableView我使用过程中它从添加/删除细胞的高度可能会改变。
使用它的最佳方法是什么AutoLayout?
- UIViewController
-- UIView
--- UIScrollView
---- UIView
----- UILabel
----- UITextField
----- UITextView
----- UITableView (at the bottom of the superview)
Run Code Online (Sandbox Code Playgroud)
或在xib中:
objective-c ×9
ios ×8
iphone ×4
xcode ×3
autolayout ×1
cocoa-touch ×1
css ×1
delegates ×1
facebook ×1
html ×1
macos ×1
nsdictionary ×1
restkit ×1
screenshot ×1
uiimageview ×1
uiscrollview ×1
uitableview ×1
uitextfield ×1
xib ×1