小编Oll*_*177的帖子

如何在内部输入时调整UITextView的大小?

我正在创建一个评论部分,就像Facebook在iOS应用程序中使用它的消息部分一样.我希望UITextView调整高度,以便我输入的文本适合它,而不是你必须滚动才能看到溢出的文本.我有什么想法可以这样做吗?我调查了可能使用的CGRect是分配给文本视图的大小和高度,然后匹配内容大小:

CGRect textFrame = textView.frame;
textFrame.size.height = textView.contentSize.height;
textView.frame = textFrame;
Run Code Online (Sandbox Code Playgroud)

我假设我需要某种功能来检测文本何时到达边界UITextView然后调整视图的高度?有没有人在用同样的概念挣扎?

iphone uitextview ios cgrect

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

使用UINavigationController轻扫手势而不是backbarbuttonitem

我环顾四周,我不能为我的生活找到一种方法来替换backbarbuttonitem滑动手势.我想向左滑动,让应用程序恢复到以前的视图控制器.只是为了澄清我正在使用a UINavigationController管理我的所有View控制器.有任何想法吗?或者这不可能吗?谢谢!

uinavigationcontroller uiswipegesturerecognizer backbarbuttonitem

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

Objective-C类别"无法识别的选择器"错误

我制作了一个UIImage Objective C类别来容纳这个功能:

    #import "UIImage+fixOrientation.h"

@implementation UIImage (fixOrientation)

- (UIImage *)fixOrientation
{

    // No-op if the orientation is already correct
    if (self.imageOrientation == UIImageOrientationUp) return self;

    // We need to calculate the proper transformation to make the image upright.
    // We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
    CGAffineTransform transform = CGAffineTransformIdentity;

    switch (self.imageOrientation) {
        case UIImageOrientationDown:
        case UIImageOrientationDownMirrored:
            transform = CGAffineTransformTranslate(transform, self.size.width, self.size.height);
            transform = CGAffineTransformRotate(transform, M_PI);
            break;

        case UIImageOrientationLeft:
        case UIImageOrientationLeftMirrored:
            transform …
Run Code Online (Sandbox Code Playgroud)

iphone uiimage nsdata objective-c-category ios6

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