我有一个UITableview
具有多个可重用的TableViewCells.在一个单元格中,我有一个UITextView
,它自己调整大小以适应其内容.现在我"只是"必须调整contentView
TableViewCell的大小,所以我可以阅读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) 我在iOS 8中使用TodayExtension,我想知道如何将模糊效果应用于文本或按钮.我已经发现它与UIVisualEffectView有关.但我不知道如何使用它.
我正在使用Objective-C
任何人都可以向我解释如何实现这一目标吗?
谢谢,大卫
我正在显示一个UIWindow UIStatusBar
,默认UIStatusBarStyle
设置为UIStatusBarStyleLightContent
,但是当我UIWindow
将UIStatusBarStyle
开关显示为黑色样式时.
我在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) 我喜欢将自己的WhatsApp添加ActivityItem
到UIActivityViewController
,但它总是添加到较低的非彩色活动栏,但我喜欢将它添加到上部栏,带有彩色项目的栏.
那是我使用的代码:
WhatsApp *whatsApp = [[WhatsApp alloc] init];
UIActivityViewController* activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[image, text] applicationActivities:@[whatsApp]];
Run Code Online (Sandbox Code Playgroud)
喜欢.
我正在为我们的本地业务开发一个应用程序.我已经有了现场摄像头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) 我遇到了XCAssets的问题.我创建了一个带有图标的自定义XCAssets文件.我从文件中得到这样的图像:
[UIImage imageNamed:@"deniedOverlay"];
Run Code Online (Sandbox Code Playgroud)
所以,现在问题.文件未复制到.app文件,因此我得到空白图像.XCAssets文件被添加到"复制包资源".我自己无法解决这个问题.
谢谢!
刚拿到我的Pebble,我正在玩SDK.我是C的新手,但我知道Objective-C.那么有没有办法创建这样的格式化字符串?
int i = 1;
NSString *string = [NSString stringWithFormat:@"%i", i];
Run Code Online (Sandbox Code Playgroud)
我不能用sprintf
,因为没有malloc
.
我基本上要显示int
与text_layer_set_text(&countLayer, i);
我正在尝试使用登录页面创建一个网页.当用户第一次登录时,浏览器将保存用户名和密码,如果他选中"保持登录状态".当他第二次登录时,浏览器将自动填写表单,我可以将其登录,而无需他与页面进行交互.
问题是,我无法从登录表单中获取密码.看看我的代码:
$(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) 我有一个带有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?
ios ×5
objective-c ×3
xcode ×3
autofill ×1
blur ×1
bundle ×1
c ×1
camera ×1
forms ×1
int ×1
ios6 ×1
ios7 ×1
ios8 ×1
javascript ×1
jquery ×1
pebble-sdk ×1
pebble-watch ×1
python ×1
qr-code ×1
raspberry-pi ×1
string ×1
uilabel ×1
uistatusbar ×1
uitableview ×1
uiwindow ×1
webview ×1
xcasset ×1