我需要删除添加的Null对象
[mutArrSkills addObject:[NSNull null]];
Run Code Online (Sandbox Code Playgroud)
我需要迭代吗?是否有任何函数可以从NSMutableArray中删除所有空值?
如果需要迭代,我该怎么做?
我有UITextField类的子类并执行以下代码
- (void)drawPlaceholderInRect:(CGRect)rect
{
[self.placeHolderTextColor setFill];
[self.placeholder drawInRect:rect
withFont:self.placeHolderFont
lineBreakMode:NSLineBreakByTruncatingTail
alignment:NSTextAlignmentLeft];
}
Run Code Online (Sandbox Code Playgroud)
我也写了
self.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
一行代码
此占位符文本在ios6中正确对齐,但在ios7中没有显示在顶部对齐.
虽然我输入的文本显示为居中.它只有占位符字符串的问题.
我已经尝试使用xib来设置占位符字符串.在XIB中它正确显示但是当我运行代码时,textfield占位符是顶部对齐的.
有什么解决方法吗?
Vadoff的回答对我有用.这仍然是完整的实现,可以帮助任何有同样问题的人.
drawInRect方法在ios7中已弃用并且drawInRectWithAttributes有效
- (void)drawPlaceholderInRect:(CGRect)rect
{
[self.placeHolderTextColor setFill];
CGRect placeholderRect = CGRectMake(rect.origin.x, (rect.size.height- self.placeHolderFont.pointSize)/2 - 2, rect.size.width, self.placeHolderFont.pointSize);
rect = placeholderRect;
if(iOS7) {
NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init];
style.lineBreakMode = NSLineBreakByTruncatingTail;
style.alignment = self.placeHolderTextAlignment;
NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys:style,NSParagraphStyleAttributeName, self.placeHolderFont, NSFontAttributeName, self.placeHolderTextColor, NSForegroundColorAttributeName, nil];
[self.placeholder drawInRect:rect withAttributes:attr];
}
else {
[self.placeholder drawInRect:rect
withFont:self.placeHolderFont
lineBreakMode:NSLineBreakByTruncatingTail
alignment:self.placeHolderTextAlignment];
} …Run Code Online (Sandbox Code Playgroud) 这是一个非常常见的问题,一次又一次地问堆栈溢出,我读了很多这方面的答案,但我仍然有点困惑.
我需要从iPhone sdk调用webservices.
这是我的问题:
我不清楚SOAP或REST返回什么响应.有什么特定的,如果响应是XML那么我们应该使用REST,如果JSON我们应该使用SOAP?
ASIHTTP与SOAP和REST的作用是什么?
如果我得到XML响应
Run Code Online (Sandbox Code Playgroud)<oproduct> <iid>113133791</iid> <icategoryid>270</icategoryid> <imerchantid>1547</imerchantid> <iadult>0</iadult> <sname>The Ashes / 1st Test - England v Australia - Day 1</sname> <sawdeeplink>http://www.acbcd.com/pclick.php?p=113133791&a=111402&m=1547&platform=cs</sawdeeplink> <sawthumburl>http://images.abcdd.com/thumb/1547/113133791.jpg</sawthumburl> <fprice>69.99</fprice> </oproduct>
我需要手工解析吗?或者我如何处理XML响应?
我收到了很多关于REST和SOAP的文章,但没有适当的代码来理解它.对于这些问题的任何帮助,我将不胜感激.
我在长按UICollectionViewCell时添加了自定义菜单控制器
[self becomeFirstResponder];
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action"
action:@selector(customAction:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]];
[[UIMenuController sharedMenuController] setTargetRect: self.frame inView:self.superview];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated: YES];
Run Code Online (Sandbox Code Playgroud)
canBecomeFirstResponder也被调用
- (BOOL)canBecomeFirstResponder {
// NOTE: This menu item will not show if this is not YES!
return YES;
}
Run Code Online (Sandbox Code Playgroud)
//未调用此方法
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
NSLog(@"canPerformAction");
// The selector(s) should match your UIMenuItem selector
if (action == @selector(customAction:)) {
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
我也实现了这些方法
- (BOOL)collectionView:(UICollectionView *)collectionView
canPerformAction:(SEL)action
forItemAtIndexPath:(NSIndexPath *)indexPath
withSender:(id)sender {
if([NSStringFromSelector(action) …Run Code Online (Sandbox Code Playgroud) 我在parse.com上有一个数据库
在哪里我有一个叫做的课 UserDetail
在那个类中,我有一个名为Field的数组 occupationid
对于这个专栏中,我有一个叫做另一个类Occupation,其中,列都是这样
occupationid,occupationname
现在我想根据存储的内容UserDetail从occupation类中获取所有数据以及所有数据occupationidUserDetail
UserDetail
用户名--contidid - 详细信息
Jhon - ["1","3","4"] - ajfdkaldjlajsdkfjaldkf
Occupation
占领 - 占领
1 - 会计师
2 - 律师
3 - 画家
4 - 作家
像明智的.
我已经阅读了该文档并且我已经PFRelation阅读了但是没有得到如何应用我的情况来获取这种数据.
我也尝试过
PFQuery *getuserdetail = [PFQuery queryWithClassName:@"UserDetail"];
[getuserdetail orderByAscending:@"celebid"];
PFQuery *getoccupation = [PFQuery queryWithClassName:@"Occupation"];
[getoccupation whereKey:@"occupationid" matchesKey:@"occupationid" inQuery:getuserdetail];
Run Code Online (Sandbox Code Playgroud)
有什么建议?我必须为其他2,3列做同样的事情.任何帮助将不胜感激.
UPDATE
数据直接在parse.com DataBrowser上添加,而不是从代码中添加.
我创建了一个类Relation中的UserDetail类,要求我添加occupationid和occupation
当我补充说我面临两个问题
1>当我尝试为不同的用户添加相同的占领时,它会为同一个创建两行occupationid.这意味着对于具有相同职业的两个用户,它在 …
我要求如果我的应用程序从后台模式终止,之后如果发生任何重要的位置更改,它应该以后台模式启动.这就是文件中的确切陈述startMonitoringSignificantLocationChanges
如果您启动此服务并且您的应用程序随后终止,则系统会在新事件到达时自动将应用程序重新启动到后台.在这种情况下,传递给应用程序的选项字典:didFinishLaunchingWithOptions:应用程序委托的方法包含密钥UIApplicationLaunchOptionsLocationKey,以指示您的应用程序是由于位置事件而启动的.重新启动后,您仍必须配置位置管理器对象并调用此方法以继续接收位置事件.重新启动位置服务时,会立即将当前事件传递给您的代理.此外,即使在启动位置服务之前,也会使用最新的位置对象填充位置管理器对象的位置属性.
所以我把这段代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
// Stop normal location updates and start significant location change updates for battery efficiency.
[viewController.locationManager stopUpdatingLocation];
[viewController.locationManager startMonitoringSignificantLocationChanges];
//NSLog(@"significantLocationChangeMonitoringAvailable.");
}
else {
//NSLog(@"Significant location change monitoring is not available.");
}
}
Run Code Online (Sandbox Code Playgroud)
之后,虽然我试图在漫游之后改变我的位置,但它还没有在后台模式中重新启动.
我在这里遗失或误导的是什么?该应用程序没有在后台重新启动
有什么建议?
编辑2013年7月12日
经过这么多次试验后,我发现应用程序在使用崩溃日志重新启动后立即崩溃
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x3ba3feb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3ba40048 mach_msg + 36
2 CoreFoundation 0x337ff040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x337fdd9e __CFRunLoopRun …Run Code Online (Sandbox Code Playgroud) iphone objective-c core-location cllocationmanager cllocation
我在 WPF 应用程序中使用 Windows 10 API“Passport”和“Window Hello”。
bool keyCredentialAvailable = await KeyCredentialManager.IsSupportedAsync();
if (keyCredentialAvailable)
{
KeyCredentialRetrievalResult keyCreationResult = await KeyCredentialManager.RequestCreateAsync("Hi", KeyCredentialCreationOption.ReplaceExisting);
}
Run Code Online (Sandbox Code Playgroud)
RequestCreateAsync方法打开弹出窗口,要求输入生物识别信息或密码。这在主窗口后面的屏幕截图中可见。
我没有任何关于这个弹出窗口的参考,我可以把它放在前面。另外,我在 MainWindow 的方法上调用此方法Loaded,以便可以确认主窗口已完全加载。
我正在我的UIImageView另一个UIView矩形.通过将平移手势应用于UIView矩形,它也可以在外面UIImageView.我不想被拖出去UIImageView
我尝试了下面的代码,但它没有那样工作
-(void)handleMovementView:(UIPanGestureRecognizer *)recognizer
{
CGPoint movement;
if(recognizer.state == UIGestureRecognizerStateBegan || recognizer.state == UIGestureRecognizerStateChanged || recognizer.state == UIGestureRecognizerStateEnded)
{
CGRect rec = recognizer.view.frame;
CGRect imgvw = self.imgViewCrop.frame;
if((rec.origin.x >= imgvw.origin.x && (rec.origin.x + rec.size.width <= imgvw.origin.x + imgvw.size.width)))
{
CGPoint translation = [recognizer translationInView:recognizer.view.superview];
movement = translation;
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointZero inView:recognizer.view.superview];
[self handleMovementForHandlers:movement];
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我慢慢地应用Pan,它会应用这个条件但是当我快速移动时它会超出ImageView
iphone objective-c uiimageview uigesturerecognizer uipangesturerecognizer
我试图格式化float如下:
1.1500将显示为"$ 1.15"
1.1000将显示为"$ 1.10"
1.0000将显示为"$ 1.00"
1.4710将显示为"$ 1.471"
1.4711将显示为"$ 1.4711"
我试过了
NSString *answer = [NSString stringWithFormat:@"$ %.2f",myvalue];
Run Code Online (Sandbox Code Playgroud) 我正在使用UITextField和UITextField.Mine是iPad应用程序
-(void)showAlertToAddLink
{
alertToAddLink =[[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ADD", nil];
alertToAddLink.tag = 2;
alertToAddLink.alertViewStyle = UIAlertViewStylePlainTextInput;
[txtLinkName setDelegate:self];
/*
UITextField *txtLinkName = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 50.0)];
[txtLinkName setDelegate:self];
// txtLinkName.text=@"";
[txtLinkName setFont:[UIFont fontWithName:@"Helvetica" size:17.0]];
[txtLinkName setTextColor:[UIColor colorWithRed:71.0/255.0 green:78.0/255.0 blue:80.0/255.0 alpha:1]];
[txtLinkName setBorderStyle:UITextBorderStyleRoundedRect];
[txtLinkName setBackgroundColor:[UIColor whiteColor]];
[txtLinkName setKeyboardAppearance:UIKeyboardAppearanceAlert];
[txtLinkName setAutocorrectionType:UITextAutocorrectionTypeNo];
[txtLinkName setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[txtLinkName setClearButtonMode:UITextFieldViewModeWhileEditing];
[txtLinkName setTextAlignment:UITextAlignmentLeft];
// [txtLinkName becomeFirstResponder];
[alertToAddLink addSubview:txtLinkName];
*/[alertToAddLink show];
}
Run Code Online (Sandbox Code Playgroud)
我试过了
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[alertToAddLink resignFirstResponder];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
但是alertview并没有被重新调整. …
objective-c ×7
iphone ×5
ios4 ×2
c# ×1
cllocation ×1
cocoa ×1
cocoa-touch ×1
ios ×1
ios5 ×1
ios7 ×1
rest ×1
soap ×1
uiimageview ×1
uiresponder ×1
uitextfield ×1
windows ×1
wpf ×1
xml ×1