小编Ste*_*hen的帖子

使用titleTextAttributes时,UINavigationbar标题被截断

我的iPhone应用程序有一个标签栏控制器,在每个标签上(4个标签)有一个UINavigationController,我希望它是一个不同的颜色,并改变标题上的字体,所以我使自己的自定义导航控制器在任何地方使用所以这些更改只有一个地方.色调很简单,工作正常,但是当我尝试使用setTitleTextAttributes设置字体时,它会更改字体,但在某些视图中,标题显示最后被截断(即"我的标题...").如果我更改视图然后返回带有截断标题的视图,标题确实会正确显示.

目前我的自定义UINavigationController中的viewDidLoad具有:

UIFont *font = [UIFont fontWithName:@"GillSans-Bold" size:22];
NSDictionary *attr = [[NSDictionary alloc] initWithObjectsAndKeys:font, UITextAttributeFont, nil];
[self.navigationBar setTitleTextAttributes:attr];
Run Code Online (Sandbox Code Playgroud)

我的想法是它正在改变titleView的字体,但它没有根据新的大小调整大小(因为它是一个更大的字体).另一个问题是,当手机转向横向时,任何挂低(g,p,y)的字母都会将底部切断.有没有办法调整标签大小或允许设置minimumFontSize,以便文本在太大时简单缩小?

uinavigationcontroller

15
推荐指数
1
解决办法
4420
查看次数

显示UIMenuController丢失键盘

我正在创建一个类似于手机上的消息应用程序的iPhone应用程序.我只是设置了通过UIMenuController复制消息的能力,但是如果键盘正在显示并且有人试图复制消息,键盘就会消失(大概是因为我[cell becomeFirstResponder];在哪里cell复制了消息单元).

有没有办法显示复制邮件而不会丢失键盘?

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

    //...other cell setup stuff...

    UILongPressGestureRecognizer *longPressGesture =
    [[UILongPressGestureRecognizer alloc]
      initWithTarget:self action:@selector(showCopyDialog:)];
    [cell addGestureRecognizer:longPressGesture];

    return cell;
}

- (void)showCopyDialog:(UILongPressGestureRecognizer *)gesture
{
    if (gesture.state == UIGestureRecognizerStateBegan)
    {
        ConvoMessageCell *cell = (ConvoMessageCell *)[gesture view];
        NSIndexPath *indexPath = [self.tblConvo indexPathForCell:cell];

        UIMenuController *theMenu = [UIMenuController sharedMenuController];
        [cell becomeFirstResponder];
        [theMenu setTargetRect:CGRectMake(menuX, menuY, 100, 100) inView:cell];
        [theMenu setMenuVisible:YES animated:YES];        
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone copy first-responder uimenucontroller

7
推荐指数
2
解决办法
2544
查看次数

layoutManager boundingRectForGlyphRange:inTextContainer:不适用于所有字符串

我有一个像字符串一样的推文的UILabel,包括其他用户的提及.

Hey @stephen and @frank and @Jason1.
Run Code Online (Sandbox Code Playgroud)

我试图让每个提及都可以点击,这样我就可以加载该用户的个人资料.我从另一个SO帖子中找到了一些代码(如何找到UGRabel中文本子字符串的CGRect?),我可以使用它来查找字符串中每个提及的位置.但是,它通常不适用于帖子中的最后一个或最后两个提及.

来自SO帖子的方法(稍加修改):

- (CGRect)boundingRectForCharacterRange:(NSRange)range
{
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:self.myLabel.attributedText];
    NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
    NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
    [textStorage addLayoutManager:layoutManager];
    NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:self.myLabel.bounds.size];
    textContainer.lineFragmentPadding = 0;
    [layoutManager addTextContainer:textContainer];

    NSRange glyphRange;

    // Convert the range for glyphs.
    [layoutManager characterRangeForGlyphRange:range actualGlyphRange:&glyphRange];

    return [layoutManager boundingRectForGlyphRange:glyphRange inTextContainer:textContainer];
}
Run Code Online (Sandbox Code Playgroud)

然后,在touchesEnded:,我循环每次提及,获取主字符串中的范围,并检查触摸是否在CGRect内.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{        
    UITouch *touch = touches.allObjects[0];

    for (NSString *mention in self.mentions) { …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

7
推荐指数
1
解决办法
2730
查看次数

由于ProbableAccessDeniedError,无法使用pika连接到Heroku上的RabbitMQ

我只是在heroku中设置了一个RabbitMQ插件.在开发我的应用程序以排队并使用在本地实例上运行的消息之后,我将其部署到Heroku并且还无法成功连接.用户名/密码和主机名/端口/ vhost均来自heroku config.如果我更改用户名或密码,错误会更改为ProbableAuthenticationError使我认为身份验证至少是正确的,但可能是我的vhost或其他一些缺少配置的问题.我没有在SO上看到任何类似的问题,也没有看到一小时的谷歌搜索没有解决我的问题.

我已经尝试了发送和消费的环境变量RABBITMQ_BIGWIG_RX_URLRABBITMQ_BIGWIG_TX_URL环境变量,但似乎没有任何组合可行.下面是我尝试连接的代码.

url = 'small-laurel-24.bigwig.lshift.net'
port = 10019
vhost = '/notmyrealvhost'

credentials = pika.PlainCredentials('username', 'password')
parameters = pika.ConnectionParameters(url, port, vhost, credentials=credentials)
connection = pika.BlockingConnection(parameters)
Run Code Online (Sandbox Code Playgroud)

有什么我缺少的东西或任何方法来弄清楚具体配置错误的是什么?我在这里不知所措.非常感谢提前!

我正在运行pika 0.9.14,python 2.7.3.

python heroku rabbitmq pika

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