小编Mud*_*til的帖子

boundingRectWithSize不复制UITextView

我在项目中的要求是UITextView应该根据内容的内容减小字体大小UITextView.所以我想用估计文本的大小boundingRectWithSize.

问题是我得到的字体有点太大,文本的某些部分会被剪裁.

我的职责:

 -(BOOL)updateTextViewFontSizeForText:(NSString*)text{

    float fontSize = self.maximumFontSizeInPoints;

    self.font = [self.font fontWithSize:fontSize];

    CGSize tallerSize ;
    CGSize stringSize ;


    do
    {
        if (fontSize <= self.minimumFontSizeInPoints) // it just won't fit
            return NO;

        fontSize -= 1.0;
        self.font = [self.font fontWithSize:fontSize];

        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping];

        NSDictionary *attributes = @{ NSFontAttributeName: self.font, NSParagraphStyleAttributeName : paragraphStyle };



        tallerSize = CGSizeMake(self.frame.size.width,self.frame.size.height-16);// the 16 is given because uitextview adds some offset
        stringSize = [text boundingRectWithSize:CGSizeMake(self.contentSize.width,CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | …
Run Code Online (Sandbox Code Playgroud)

objective-c ios ios7

5
推荐指数
2
解决办法
1006
查看次数

uitableviewCell 分隔线

嗨,我是 ios 开发的新手。我正在开发一个应用程序,我在其中使用UITableView. Tableview包含一些带分隔线的单元格和其他不带分隔线的单元格。任何人都可以告诉我如何删除特定单元格的分隔线?

cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, cell.bounds.size.width);
Run Code Online (Sandbox Code Playgroud)

上面的代码适用于iOS 7. 我怎样才能做到这一点iOS6?任何帮助表示赞赏

uitableview ios ios6

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

正则表达式匹配字母数字,连字符,下划线和空格字符串

我正在尝试匹配包含字母数字,连字符,下划线和空格的字符串.

连字符,下划线,空格和数字是可选的,但第一个和最后一个字符必须是字母.

例如,这些都应该匹配:

abc
abc def
abc123
ab_cd
ab-cd
Run Code Online (Sandbox Code Playgroud)

我试过这个:

^[a-zA-Z0-9-_ ]+$
Run Code Online (Sandbox Code Playgroud)

但它在开始/结束时与空格,下划线或连字符匹配,但它只允许介于两者之间.

regex

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

Compiler Error with LLVM 5.1 "Deprecated isa"

I am getting compiler errors with libJSONKit and in JSONKit.m. The errors are thrown with this: "Assignment to Objective-C's isa is deprecated in favor of object_setClass()".
There is also a secondary error: "Direct access to Objective-C's isa is deprecated in favor of object_getClass()".

Any advice on workarounds or solutions?

json llvm ios jsonkit

3
推荐指数
1
解决办法
2855
查看次数

-tableView:cellForRowAtIndexPath:没有被调用

我已经UITableView进入UIViewController并通过outlet和delegete连接,并且数据源被分配给自己.numberOfSectionsInTableView并且numberOfRowsInSection正在调用我尝试使用NSLog但是cellForRowAtIndexPath没有调用我的代码看起来像

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    NSLog(@" cellForRowAtIndexPath ");

    static NSString *CellIdentifier = @"CurrencyCell";

    CurrencyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[CurrencyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
    }
    new *Obj = [appdelegate.array objectAtIndex:indexPath.row];


    cell.CurNameLabel.text = Obj.C_Name;
    cell.textLabel.text = @"sdfnhsdfndsio;";
    NSLog(@"C_Name %@", Obj.C_Name);

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

任何一个电话我都会犯错误提前谢谢

iphone uitableview xcode4 ios5

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

Parent-Iframe postMessage 通信

我正在尝试在父窗口和其中包含的 iframe 之间建立一个简单的 postmessage 通信。我在父端得到了这个代码:

var ifr = document.getElementById("ifr");

ifr.contentWindow.postMessage('hello child, this is parent', '*');

window.addEventListener('message', function (e) { console.log(e.data) });
Run Code Online (Sandbox Code Playgroud)

在孩子方面,我有:

window.parent.postMessage('hello parent, this is child', '*')

window.addEventListener('message', function (e) {console.log(e.data) } );
Run Code Online (Sandbox Code Playgroud)

我收到了 iframe 发送的消息,但没有收到父级发送的消息,我已经检查过并且 get 正确选择了 iframe 元素。这仅用于测试目的以用于其他用途。

javascript iframe

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

Linphone for iPhone在进入后台模式时没有接听电话

我已经linphone在我的应用程序中集成了sdk.当我的应用程序进入后台模式时,我的应用程序没有收到任何来电.我想让我的应用程序工作就像skype进入后台模式一样.

我在info.plist中添加了所需的后台模式.

  Application does not run in background  - NO
  Required background modes
    item 1        App provides Voice over IP services
Run Code Online (Sandbox Code Playgroud)

我已经实现了以下方法ApplicationDidEnterBackground,但我仍面临同样的问题.

1.setKeepAliveTimeout:handler:
  [http://www.linphone.org/docs/liblinphone/group__IOS.html][1]
Run Code Online (Sandbox Code Playgroud)

请帮帮我.提前致谢.

background ios linphone

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

UIWebView在底部被UITabBarController切断

UITabBarController在应用程序的底部有一个,对于一个视图,我想显示许多组件UIWebView,在底部有一个和UITabBarController。我的问题是我UIWebView被我的底部切断了,UITabBarController因为在我的.xib中,我UIWebView占用了所有剩余空间。

如何以编程方式解决WebView知道何时必须停止显示(正好在我的顶部之前UITabBarController)的问题?我想要IOS6 / 7的解决方案。

非常感谢你!

objective-c uiwebview uitabbarcontroller uitabbar ios

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

混合两个PFQuery结果

我希望得到两个PFQuery结果的混合.在下面的代码中,我得到了两个结果的交集结果(所以用户名和fullName包含的所有用户都有self.searchText),我想要包含所有结果(所以用户名为equals的self.searchText所有用户和所有fullName等于的用户)self.searchText).

PFQuery *query = [PFUser query];
[query whereKey:@"username" containsString:self.searchText];
[query whereKey:@"fullName" containsString:self.searchText];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (error) {
        NSLog(@"%@ %@", error, [error userInfo]);
    } else {
        self.searchResults = [[NSMutableArray alloc] initWithArray:objects];
        NSLog(@"%@", objects);
        [self.tableView reloadData];
    }
}];
Run Code Online (Sandbox Code Playgroud)

objective-c ios parse-platform pfquery

0
推荐指数
1
解决办法
1274
查看次数