小编Bha*_*ani的帖子

如何知道UITableview行号

我有一个UITableViewCellUISwitch作为accessoryView的每一个细胞.当我更改单元格中交换机的值时,如何知道交换机在哪一行?我需要切换值更改事件中的行号.

iphone uitableview uiswitch ios

38
推荐指数
2
解决办法
2万
查看次数

子类UIButton添加属性

我想子类UIButton添加一些我需要的属性(不是方法...只有属性).

这是我的子类的代码:

//.h-----------------------
@interface MyButton : UIButton{
    MyPropertyType *property;
}

@property (nonatomic,retain) MyPropertyType *property;
@end

//.m--------------------------
@implementation MyButton
@synthesize property;

@end
Run Code Online (Sandbox Code Playgroud)

在这里我如何使用该类:

MyButton *btn = ((MytButton *)[MyButton buttonWithType:UIButtonTypeRoundedRect]);
btn.property = SomeDataForTheProperty;
Run Code Online (Sandbox Code Playgroud)

从哪里获得此错误:

 -[UIRoundedRectButton setProperty:]: unrecognized selector sent to instance 0x593e920
Run Code Online (Sandbox Code Playgroud)

因此,从ButtonWithType我获得一个UIRoundedRectButton,(Mybutton *)不能施展它...我需要做什么来获得一个MyButton对象?是-init唯一的解决方案?

谢谢!

iphone objective-c uibutton ios

34
推荐指数
2
解决办法
2万
查看次数

锁定MFMailComposeViewController中的字段

是否有可能以某种方式锁定字段,MFMailComposeViewController以便用户无法更改正文,收件人等?我需要用户发送的电子邮件去特定帐户和身体符合某些标准,所以如果用户大幅度编辑格式,一切都可能会出现可怕的错误.当时正文从用户的数据填充输入到上一个视图中的文本字段和日期选择器.

基本上我认为将字段锁定而不是显示警告或者说"请不要编辑消息"这样更专业,所以如果字段无法锁定,这不是一个大问题,但任何帮助我将不胜感激.

email iphone locking ios mfmailcomposeviewcontroller

24
推荐指数
1
解决办法
2万
查看次数

Swift 3 NSAttributedString多个属性

刚开始swift 3我遇到了快速语法问题.

我想要显示一个简单的NSAttributedString.

所以我先设定我的属性:

let attributeFontSaySomething : [String : AnyObject] = [NSFontAttributeName : UIFont.fontSaySomething()]
let attributeColorSaySomething : [String : AnyObject] = [NSForegroundColorAttributeName : UIColor.blue]
Run Code Online (Sandbox Code Playgroud)

然后我创建我的字符串:

let attStringSaySomething = NSAttributedString(string: "Say something", attributes: self.attributeFontSaySomething)
Run Code Online (Sandbox Code Playgroud)

我想要做的是创建具有我的2个属性的字符串,而不仅仅是一个.但当我这样做时:

let attStringSaySomething = NSAttributedString(string: "Say something", attributes: [self.attributeFontSaySomething, self.attributeColorSaySomething])
Run Code Online (Sandbox Code Playgroud)

Xcode告诉我,我不能并希望我为字典词典更改此内容.

如何在不使用NSMutableAttributedString?的情况下使用2个属性创建字符串?

nsattributedstring ios

15
推荐指数
2
解决办法
3万
查看次数

使用Reachability for Internet*或*本地WiFi?

我搜索过这个问题的答案,并没有真正解决,至少在某些方面我无法解决这个问题.

我最初只是检查Internet可达性,使用:

self.wwanReach = [Reachability reachabilityWithHostName:@"www.apple.com"];
[wwanReach startNotifer];
Run Code Online (Sandbox Code Playgroud)

我现在需要支持本地WiFi连接(一般没有上网),当我发现时+reachabilityForLocalWiFi,我也注意到了+reachabilityForInternetConnection.我想我可以使用这些,而不是"www.apple.com"在那里进行硬编码,但唉,当我使用时:

self.wwanReach = [Reachability reachabilityForInternetConnection];
[wwanReach startNotifer];
self.wifiReach = [Reachability reachabilityForLocalWiFi];
[wifiReach startNotifer];
Run Code Online (Sandbox Code Playgroud)

我设置的"永不"的可达性回调被调用,对于"永不"的值,最多10分钟,12分钟,15分钟左右(这只要我的耐心持续.)(用户的耐心会少得多,我确定.)切换回+ reachabilityWithHostName:在几秒钟内工作.我也单独尝试了每个"对",以防两个通知程序同时出现问题,但没有区别.

那么:确定Internet/WWAN或本地Wifi网络(一个或两个)的可达性的适当方法是什么?

[此特定用例是连接到Mac mini计算机到计算机网络的iPhone或iPad; 我确定其他情况适用.]

iphone networking cocoa reachability

11
推荐指数
2
解决办法
1万
查看次数

在iOS上为NSFileManager获取root权限(越狱)

我正在尝试将文件写入设备的根分区.它是一个Jailbreak应用程序,因此它安装在/ Applications中.使用写入写入根文件系统NSFileManager失败时出现"权限被拒绝"错误.

好像我的应用程序没有以root用户身份运行.它安装在/ Applications中.我的应用程序如何成为root用户?

filesystems objective-c jailbreak ios

11
推荐指数
1
解决办法
1万
查看次数

构建复杂的NSCompoundPredicate的最佳方法是什么?

我需要构建一个NSPredicate包含许多数据的数据.例如在SQL中我会做类似以下的事情:

SELECT * 
  FROM TRANSACTIONS
  WHERE CATEGORY IN (categoryList)
    AND LOCATION IN (locationList)
    AND TYPE IN (typeList)
    AND NOTE contains[cd] "some text"
    AND DATE >= fromDate
    AND DATE <+ toDate
Run Code Online (Sandbox Code Playgroud)

我正在努力将其构建NSPredicate为与Core Data一起使用.我已经阅读了文档......它只提供了简单的例子.如果有人能指出一个更复杂的例子,我当然会很感激.


好吧,我在这里得到了两年的答案,很多人都觉得有帮助.我的帖子被删除了.以下是解决方案的更新URL.

https://www.radeeccles.com/convert-sql-statement-to-an-nspredicate-for-use-with-core-data/

sql core-data nspredicate ios

10
推荐指数
1
解决办法
4650
查看次数

IBInspectable UIEdgeInsets未在IBOutlet中显示

我正在创建一个自定义类UIButton来增加挖掘区域.我需要用户可以在故事板中输入填充.所以我做了一个IBInspectable房产.

@IBDesignable class UIIconButton: UIButton {
    @IBInspectable var touchPadding:UIEdgeInsets = UIEdgeInsetsZero
}
Run Code Online (Sandbox Code Playgroud)

但它没有在故事板中显示.但是,如果用CGRect它替换它,那么它在故事板中是可见的.

storyboard xib ios ibinspectable xcode7

10
推荐指数
1
解决办法
2066
查看次数

SFSpeechRecognizer无法正确处理上下文字符串

SFSpeechRecognizer我的用例非常不准确.我已经尝试设置contextual字符串,因为我有一个与之匹配的单词数组.但它仍然无法做到这一点.我还需要其他配置吗?

我正在使用Apple提供的示例项目,只有这个改变:

recognitionRequest.contextualStrings = @[@"iron man", @"metal", @"stark", @"superhero", @"boyfriend", @"pepper", @"arrogant", @"stylish"];
Run Code Online (Sandbox Code Playgroud)

objective-c ios sirikit sfspeechrecognizer

9
推荐指数
1
解决办法
640
查看次数

UIImage调整大小不正常

所以我一直试图弄清楚我现在做错了一段时间,我无法弄明白.我想要完成的是:

  1. 拍张照片 UIImagePickerController
  2. 拍摄照片并从顶部和底部裁剪,使其成为正方形(类似于Instagram)
  3. 在a中显示该图像 UIButton

出于某种原因,每次我拍摄照片时都会在照片内失真UIButton,看起来好像裁剪不能正常工作.这就是我的工作.在didFinishPickingMediaWithInfo方法中我有以下代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    //Copy the image to the userImage variable
    [picker dismissModalViewControllerAnimated:YES];
    userImage = nil;

    //Rotate & resize image
    userImage = [self resizeAndRotatePhoto:(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage]];
    NSLog(@"Userimage size, width: %f , height: %f", userImage.size.width , userImage.size.height);

    //Update the image form field with the image and set the image in the controller
    NSLog(@"Button size is height: %f , width: %f" , userImageAvatarButton.frame.size.height , userImageAvatarButton.frame.size.width);
   [userImageAvatarButton.layer setMasksToBounds:YES];
   [userImageAvatarButton.layer setCornerRadius:3.0]; …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios4 ios ios5

8
推荐指数
1
解决办法
6350
查看次数