小编Dav*_*ser的帖子

如何调整UITableViewCell的大小以适应其内容?

我有一个UITableview具有多个可重用的TableViewCells.在一个单元格中,我有一个UITextView,它自己调整大小以适应其内容.现在我"只是"必须调整contentViewTableViewCell的大小,所以我可以阅读while文本.我已经尝试过:

cell2.contentView.bounds.size.height = cell2.discriptionTextView.bounds.size.height; 
Run Code Online (Sandbox Code Playgroud)

要么:

cell2.contentView.frame = CGRectMake(0, cell2.discriptionTextView.bounds.origin.y,     
cell2.discriptionTextView.bounds.size.width,     
cell2.discriptionTextView.bounds.size.height); 
Run Code Online (Sandbox Code Playgroud)

在方法中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath 
*)indexPath {}  
Run Code Online (Sandbox Code Playgroud)

但它不会起作用.

有谁知道如何做到这一点?

新代码:

    @implementation AppDetail

    CGFloat height;
    …

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

    cell2.TextView.text = self.text;
            [cell2.TextView sizeToFit];
            height = CGRectGetHeight(cell2.TextView.bounds);
     …
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

        if (indexPath.row == 0) {
            return 143;
        }
        if (indexPath.row == 1) {
            return height;
        }

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

objective-c uitableview ios

20
推荐指数
4
解决办法
3万
查看次数

如何在通知中心(iOS 8)中复制模糊文本

我在iOS 8中使用TodayExtension,我想知道如何将模糊效果应用于文本或按钮.我已经发现它与UIVisualEffectView有关.但我不知道如何使用它.

我正在使用Objective-C

任何人都可以向我解释如何实现这一目标吗?

谢谢,大卫

在此输入图像描述

blur uilabel ios8

20
推荐指数
2
解决办法
9011
查看次数

在UIStatusBar上显示UIWindow后,UIStatusBarStyle发生了变化

我正在显示一个UIWindow UIStatusBar,默认UIStatusBarStyle设置为UIStatusBarStyleLightContent,但是当我UIWindowUIStatusBarStyle开关显示为黑色样式时.

xcode uiwindow ios uistatusbar

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

对UIWebView使用UIRefreshControl

我在iOS 6中看到了UIRefreshControl,我的问题是,是否可以通过拉下来刷新WebView,而不是让它像邮件一样弹出?我使用rabih的代码是WebView:

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
    [rabih addSubview:rabih];
Run Code Online (Sandbox Code Playgroud)

xcode webview ios ios6

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

如何在UIActivityViewController中向Activity活动栏添加ActivityItem?

我喜欢将自己的WhatsApp添加ActivityItemUIActivityViewController,但它总是添加到较低的非彩色活动栏,但我喜欢将它添加到上部栏,带有彩色项目的栏.

那是我使用的代码:

WhatsApp *whatsApp = [[WhatsApp alloc] init];
            UIActivityViewController* activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[image, text] applicationActivities:@[whatsApp]];
Run Code Online (Sandbox Code Playgroud)

喜欢.在此输入图像描述

objective-c ios uiactivityviewcontroller ios7

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

如何为iOS创建QR码阅读器

我正在为我们的本地业务开发一个应用程序.我已经有了现场摄像头UIImageView,现在我需要知道如何从中读取QR码UIImageView并在标签中显示内容(0000-KKP0-2013).

所以基本上我需要一个QR码扫描器,它正在读取QR码并将内容保存在一个字符串中.我已经使用过ZXing("Zebra Crossing"),但它与iOS 6不兼容,它不起作用.是否有一个简单的代码来获取字符串中的QR码内容?

谢谢!

这是我在.m文件中使用的代码:

#import "ZBarSDK.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize vImagePreview;             

- (void)viewDidUnload
{
    [super viewDidUnload];

    vImagePreview = nil;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];


    //----- SHOW LIVE CAMERA PREVIEW -----
    AVCaptureSession *session = [[AVCaptureSession alloc] init];
    session.sessionPreset = AVCaptureSessionPreset352x288;

    /*CALayer *viewLayer = self.vImagePreview.layer;
    NSLog(@"viewLayer = %@", viewLayer);*/

    AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

    captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
    [self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];

    AVCaptureDevice *device = [self frontCamera];

    NSError *error = nil;
    AVCaptureDeviceInput *input = …
Run Code Online (Sandbox Code Playgroud)

camera qr-code objective-c

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

XCAssets未复制到应用程序包

我遇到了XCAssets的问题.我创建了一个带有图标的自定义XCAssets文件.我从文件中得到这样的图像:

[UIImage imageNamed:@"deniedOverlay"];
Run Code Online (Sandbox Code Playgroud)

所以,现在问题.文件未复制到.app文件,因此我得到空白图像.XCAssets文件被添加到"复制包资源".我自己无法解决这个问题.

谢谢!

xcode bundle ios xcasset

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

如何使用C中的Pebble SDK将int转换为字符串

刚拿到我的Pebble,我正在玩SDK.我是C的新手,但我知道Objective-C.那么有没有办法创建这样的格式化字符串?

int i = 1;
NSString *string = [NSString stringWithFormat:@"%i", i];
Run Code Online (Sandbox Code Playgroud)

我不能用sprintf,因为没有malloc.

我基本上要显示inttext_layer_set_text(&countLayer, i);

c string int pebble-watch pebble-sdk

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

检测登录表单的自动填充

我正在尝试使用登录页面创建一个网页.当用户第一次登录时,浏览器将保存用户名和密码,如果他选中"保持登录状态".当他第二次登录时,浏览器将自动填写表单,我可以将其登录,而无需他与页面进行交互.

问题是,我无法从登录表单中获取密码.看看我的代码:

$(document).ready(setTimeout(function() {
  loginForm.form.submit(function(e) { // I don't have a onsubmit action defined on the login form
    console.log("Submit");
    checkLogin(); // This function should get the username and password value and makes a credential check but I cant get the password here
  });
  var username = $(".login-form__username").val();
  var password = $(".login-form__password").val(); // This always is "", an empty string!
  if (username) { // If the username is set we assume its an autofill
    console.log("autofilled");
    loginForm.form.submit(); // I manually fire the …
Run Code Online (Sandbox Code Playgroud)

javascript forms jquery autofill

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

如何检测计算机是否通过Python与Internet联系?

我有一个带有WiFi加密狗的Raspberry Pi,因此标准互联网LED不起作用.我试着编写一个脚本来切换LED,无论Pi是否有互联网.

这就是我现在所拥有的:

#!/usr/bin/python
import urllib2 
import time, os

os.system("gpio mode 6 out && gpio mode 5 out")

loop_value = 1

while (loop_value == 1):
    try:
        urllib2.urlopen("http://www.google.com")
    except urllib2.URLError, e:
        time.sleep( 1 )
        print "Not Connected"
        os.system("gpio write 6 0 && gpio write 5 1")
    else:
       print "Connected"
       os.system("gpio write 6 1 && gpio write 5 0")
       loop_value = 1
Run Code Online (Sandbox Code Playgroud)

问题是那是行不通的.谁能告诉我如何检测到我的pi是否有互联网,然后打印切换LED?

python raspberry-pi

6
推荐指数
1
解决办法
7973
查看次数