每当我想从plist文件中获取数据时,我都使用以下代码:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FILE_NAME" ofType:@"plist"];
NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)
但是现在我正在尝试从Info plist中读取数据,而filePath是零.是否有不同的方法从Info plist获取数据?
我有一个UILabel应该是两行长.该文本已本地化为法语和英语.
我正在设置标签的attributedText属性.该文本由三个附加的字符串构成,例如textFragment1,textFragment2和textFragment3.中间字符串实际上是使用NSTextAttachment创建的图像.
我想确保textFragment2和textFragment3在同一行.第一个字符串可能会或可能不会换行,具体取决于它的长度.问题是我的法语文本目前相当短,所以该行在textFragment2之后换行.
我通过在textFragment1的本地化法语文本中添加换行符来暂时修复此问题.我不喜欢这个解决方案.我想知道是否有办法处理textFragment2和textFragment3,以便它们将始终在同一行上.
当我创建自定义UIViews时,我通常首先创建一个xib文件,然后在Attributes Inspector中将Simulated Metrics部分中的Size属性更改为None,这样我就可以将视图调整为我想要的大小.我想知道,这个设置和Freeform设置有区别吗?我正在使用Xcode 4.6.
我有一个UILocalNotification应该每周一次,周一到周五开火,但不是在周末.我认为将通知的repeatInterval属性设置为NSWeekdayCalendarUnit可以实现此目的.可悲的是,我的通知仍在周末开火.谁有人建议为什么?这是我的代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertAction = @"View";
localNotification.alertBody = NSLocalizedString(@"ALERT_MESSAGE", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Toronto"]];
// Notification fire times are set by creating a notification whose fire date
// is an arbitrary weekday at the correct time, and having it repeat every weekday
NSDate *fireDate = [dateFormatter dateFromString:@"01-04-2012 11:00"];
localNotification.fireDate = fireDate;
localNotification.repeatInterval = NSWeekdayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
break;
[localNotification release];
Run Code Online (Sandbox Code Playgroud) 我有一个像这样设置的UIButton:
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.backgroundColor = [UIColor redColor];
[self addSubview:button];
[button setTitle:@"myButton" forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
结果看起来像这样(非红色是按钮后面的背景):

如果我设置[button setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)]结果看起来一样.
如果我设置[button setContentEdgeInsets:UIEdgeInsetsMake(1, 0, 1, 0)]结果如下:

如果我设置[button setContentEdgeInsets:UIEdgeInsetsMake(-1, 0, -1, 0)]结果如下:

为什么看起来像1.0的顶部和底部有一个正内容插入会给出一个小于0的内容(我从文档中理解这是默认的)?我在Xcode 6和iOS 7中运行.
我创建一个自定义MKAnnoationView如下:
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKAnnotationView* customPinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
UIImage *pinImage = [PowerPlantAnnotation getAnnotationImageForEnergySource:((PowerPlantAnnotation*)annotation).energySource];
customPinView.image = pinImage;
return customPinView;
}
Run Code Online (Sandbox Code Playgroud)
我得到的图像或多或少位于正确的位置,但并不完全.我的图片看起来像这样:

我希望泪滴的底点指向我的注释贴图坐标,就像标准的针脚视图指向地图坐标一样.我怎么能做到这一点?目前看起来更像是我的图像以地图坐标为中心.
更新:我已经意识到,如果用户已经授予Facebook访问我的应用程序,然后重新安装我的应用程序,则只会出现以下问题.用户第一次在我的应用程序中选择Facebook按钮时,会转到Facebook应用程序进行身份验证,但由于身份验证状态仍保存在Facebook应用程序中,因此会立即返回到我的应用程序而无需向用户解释,并且postToFacebookWall方法失败.
更新2:我最终实现了这里找到的解决方案:如何使用新的Facebook Connect iOS API通过DIALOG授权用户?并避免使用Facebook应用程序.Safari更好,因为至少用户会收到一条消息,告知他们将登录.但Feed对话仍然是第一次失败.
我有一个常见的问题,但我还没有找到解决方案.请注意,我的应用仅限于iOS 5及更高版本.
我有一个带有Facebook按钮的应用程序,可以发布到用户墙.按下按钮后,应用程序将检查用户是否已授予应用程序发布到墙上的权限.如果有,则会弹出一个带有墙贴信息的Feed对话框.如果没有,Safari将被打开,用户将被允许登录.登录后,它们将被带回应用程序,并会弹出Feed对话框视图.
这适用于模拟器,如果未安装Facebook应用程序,则可在我的设备上使用.如果安装了Facebook应用程序,用户将被带到Facebook应用程序,但随后立即返回到原始应用程序,而不允许用户执行任何操作.弹出Feed对话框,但它完全空白并自动关闭.再次按下Facebook按钮将显示"订阅源"对话框视图,因为一旦用户授权应用程序发布到他们的墙上,它就应该显示.
我几乎遵循了这里的说明:http: //developers.facebook.com/docs/mobile/ios/build/#implementsso
在这里:http: //developers.facebook.com/docs/reference/dialogs/feed/
在AppDelegate中,我有以下代码:
- (void)loginToFacebook
{
// Set up facebook
self.facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![self.facebook isSessionValid]) {
[self.facebook authorize:nil];
}
}
// This is an FBSessionDelegate protocol method
// that gets called after a successful login
- (void)fbDidLogin
{ …Run Code Online (Sandbox Code Playgroud) 我在iTunes Connect中提交了应用更新,并将版本发布控件设置为Hold for Developer Release.我想将其更改为自动发布(它仍在等待审核).这是可能的,如果是这样,我该如何进行此更改?
我是第一次使用svn:ignore属性,所以我可能会误解某些东西.
我正在开发一个iOS应用程序.我有一个Xcode项目,我想忽略xcuserdata文件夹.使用Mac终端应用程序,我转到我的svn存储库的根目录并尝试使用以下命令忽略该文件夹:
svn propset svn:ignore path/to/my/folder/MyProject.xcodeproj/xcuserdata .
Run Code Online (Sandbox Code Playgroud)
如果我使用以下命令检查svn:ignore属性:
svn propedit svn:ignore .
Run Code Online (Sandbox Code Playgroud)
我知道了:
path/to/my/folder/MyProject.xcodeproj/xcuserdatata
Run Code Online (Sandbox Code Playgroud)
我已经提交并更新了,但我做了一个svn状态,我还是看到了一个文件夹?在它旁边标记.有谁知道我做错了什么?我使用的是svn版本1.6.17(r1128011).
编辑添加我的问题似乎与此类似:SVN只是不会忽略文件夹,尽管propset svn:ignore,但在我的情况下,我想忽略的文件夹中没有任何文件似乎被添加到svn,也没有是我想要忽略的文件夹添加到svn.
我将钟表臂指向12点钟到当前时间.如果是,11点,我想让手臂顺时针旋转到11点位置.但当然如果我使用:
CGAffineTransform rotation = CGAffineTransformMakeRotation(2*M_PI*11/12);
[UIView animateWithDuration:3.0
animations:^{
clockArm.transform = rotation;
}];
Run Code Online (Sandbox Code Playgroud)
旋转逆时针旋转.我试过了:
CGFloat angle = 2*M_PI*11/12;
CGAffineTransform firstRotation = CGAffineTransformMakeRotation(M_PI-0.001);
CGFloat firstRotationTime = 3.0*(M_PI/angle);
CGAffineTransform secondRotation = CGAffineTransformMakeRotation(angle);
CGFloat secondRotationTime = 3.0 - firstRotationTime;
[UIView animateWithDuration:firstRotationTime
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.clockArm1.transform = firstRotation;
}
completion:^(BOOL finished) {
[UIView animateWithDuration:secondRotationTime
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.clockArm1.transform = secondRotation;
}
completion:^(BOOL finished){
}];
}];
Run Code Online (Sandbox Code Playgroud)
动画确实是顺时针方向,但它很不稳定 - 动画似乎仍在为第一个动画做一个UIViewAnimationEaseInOut.我做错了什么,还是有另一种方法可以实现我的目标?
ios ×8
ios5 ×3
xcode ×3
objective-c ×2
facebook ×1
ios7 ×1
iphone ×1
mapkit ×1
mkannotation ×1
svn ×1
uibutton ×1
uiedgeinsets ×1
uikit ×1
uilabel ×1