我想用a tableView在动态单元列表的顶部有2个静态单元.据我了解,我必须使用动态原型tableView.但我不明白如何添加2个静态单元并设计它们,例如.将文本字段添加到第一个,将标签添加到第二个.
我的故事板里有什么要做的?在Controller内部我需要做什么?如何区分静态和动态细胞?
有人可以给我一个血腥的初学者一些指导从哪里开始?非常感谢!!
编辑:我试过这个测试:
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cardCell", forIndexPath: indexPath) as CardTableViewCell
//static cell
if (indexPath.row < 2) {
cell.dyn.text = "static \(indexPath.row)"
return cell;
}
// Configure the cell...
cell.dyn.text = "buh"
return cell
}
Run Code Online (Sandbox Code Playgroud)
结果如下:

后来,当我使用真实数据时,我将错过前2个数据行...在创建静态单元格后,我可以以某种方式"重置"行计数器吗?
我怎样才能修改2个静态单元?用于添加文本字段和标签?或者我必须以编程方式执行此操作?
有没有办法在iPhone上获取mnc和mcc号码?
我有UILabel,其中包含动态文本.有时文本太长而无法显示,因此会自动截断.如何找出截断文本的可见部分的宽度?
sizeThatFits返回未截断文本的长度,所以目前我只能检测何时进行截断.需要知道多少是可见的,包括那三个点.有小费吗?
澄清:当文本被截断时,它通常比UILabel宽度短.
我有一个类似于笔记应用程序的视图 - 即在一张带衬里的纸上打字.为了使文本和纸张同时滚动,我已经禁用了UITextView的滚动,而是将我的UITextView和我的UIImageView放在UIScrollView中.
唯一的问题是,当用户键入时,文本消失在键盘下方,因为显然UIScrollView不知道滚动到光标位置.
有没有简单的方法可以检索光标位置并告诉UIScrollView在那里滚动?
- -编辑 - -
从这里类似的东西开始(有人试图用UITableView做类似的事情),我已经设法制作了一个不断增长的,可编辑的UITextView,它具有几乎完全滚动的固定背景.现在唯一的问题是:
这是代码 - 如果有人能进一步完善它,我将非常感激...
#import "NoteEditViewController.h"
#import "RLWideLabelTableCell.h"
@implementation NoteEditViewController
@synthesize keyboardSize;
@synthesize keyboardHideDuration;
@synthesize scrollView;
@synthesize noteTextView;
//
// Dealloc and all that stuff
//
- (void)loadView
{
[super loadView];
UIScrollView *aScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.scrollView = aScrollView; [aScrollView release];
self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, noteTextView.frame.size.height);
[self.view addSubview:scrollView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Get notified when keyboard is shown. Don't …Run Code Online (Sandbox Code Playgroud) 在生产环境中如何从XCGLogger中完全禁用日志?
目前我正在使用logLevel = .None.
这是推荐的方式吗?
我有一个带有NSIndexPaths的NSArray
NSArray *array = [self.tableView indexPathsForSelectedRows];
for (int i = 0; i < [array count]; i++) {
NSLog(@"%@",[array objectAtIndex:i]);
}
Run Code Online (Sandbox Code Playgroud)
NSLog返回:
<NSIndexPath 0x5772fc0> 2 indexes [0, 0]
<NSIndexPath 0x577cfa0> 2 indexes [0, 1]
<NSIndexPath 0x577dfa0> 2 indexes [0, 2]
Run Code Online (Sandbox Code Playgroud)
我试图从indexPath获取第二个值只是一个普通的NSInteger
我正在使用带有cameraOverlayView的拾取器控制器在摄像机视图中显示产品的图像.在应用叠加层之前,会调整产品图像的大小.它在iOS 4.2上运行良好,但在iOS 4.3上,产品图像显示为完整大小.
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
UIImageView *imgView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:produitAffiche.img_realite]] autorelease];
// Resize
if(imgView.frame.size.height == 480)
{
//Portrait
imgView.frame = CGRectMake(80.0f, 120.0f, 160.0f, 240.0f);
}
else
{
// Landscape
imgView.frame = CGRectMake(40.0f, 160.0f, 240.0f, 160.0f);
}
imgView.contentMode = UIViewContentModeCenter;
imgView.clipsToBounds = NO;
imgView.contentMode = UIViewContentModeScaleAspectFit;
pickerController.cameraOverlayView = (UIView *) imgView;
Run Code Online (Sandbox Code Playgroud)
我更改了我用作叠加层的UIImageView的帧,但它仍然以320*480显示.我知道cameraOverlayView已经在iOS 4.3中进行了修改,但我不知道发生了什么变化以及我需要做些什么来纠正我的应用程序.
谢谢你的帮助.
我有一个过滤器按钮,在弹出窗口中显示UITableView.我有我的类别和"全部"按钮,表示没有像iTunes中那样存在过滤器.
我的applicationDelegate类中有一个NSMutableDisctionary,用于设置复选标记.当应用程序启动时,仅选择All,取消选择其他所有内容.我想要的是当选择不是"All"的行时,该行被选中,All被取消选择.类似地,当选择All时,带有复选标记的所有行都不再具有复选标记,并且仅选中All并带有复选标记(例如应用程序启动时).在我的UITableView didSelectRowForIndexPath:中,我这样做了:
MyAppAppDelegate *dmgr = (MyAppAppDelegate *)[UIApplication sharedApplication].delegate;
NSUInteger row = [indexPath row];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// All selected
if (row == 0) {
for (NSString *key in dmgr.CategoryDictionary) {
[dmgr.CategoryDictionary setObject:[NSNumber numberWithBool:NO] forKey:key];
}
[dmgr.CategoryDictionary setObject:[NSNumber numberWithBool:YES] forKey:@"All"];
}
else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
NSString *key = [_categoriesArray objectAtIndex:row];
BOOL valueAtKey = [[dmgr.CategoryDictionary valueForKey:key] boolValue];
valueAtKey = !valueAtKey;
[dmgr.CategoryDictionary setObject:[NSNumber numberWithBool:valueAtKey] forKey:key];
}
Run Code Online (Sandbox Code Playgroud)
两个问题.首先,当我选择第一行(全部)时,我收到此错误:
Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSCFDictionary: 0x597b3d0> …Run Code Online (Sandbox Code Playgroud) 在做了一些搜索和编辑之后,我似乎无法找到修复此错误的解决方案.我正在尝试将我的位置搜索结果与表格链接,以便以列表形式显示搜索结果.
我的地图上有详细信息按钮,链接到名为'FirstViewController'的UIViewController.我的结果表与一个名为'ResultsTableViewController'的UITableViewController链接.我的原型单元与名为'ResultsTableCell'的UITableViewCell链接,这也是我的网点所在的位置.
以下是两个单独的错误:
非法配置:ResultsTableViewController到UILabel的nameLabel出口无效.插座无法连接到重复内容.
非法配置:ResultsTableViewController到UILabel的phoneLabel出口无效.插座无法连接到重复内容.
我已经阅读了同样问题的其他人的帖子,试图相应地修复它们,我仍然得到同样的错误.
以下是填充单元格的代码,位于ResultsTableViewController中.
let cell = tableView.dequeueReusableCellWithIdentifier("resultCell", forIndexPath: indexPath) as! ResultsTableCell
// Configure the cell...
let row = indexPath.row
let item = mapItems[row]
cell.nameLabel.text = item.name
cell.phoneLabel.text = item.phoneNumber
return cell
}
Run Code Online (Sandbox Code Playgroud)
我的ResultsTableCell类中的代码:
import UIKit
class ResultsTableCell: UITableViewCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var phoneLabel: UILabel!
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Mac 终端上project.pbxproj使用sedshell 命令修改Xcode 项目的文件以替换字符串。我想替换该字段 -
PRODUCT_BUNDLE_IDENTIFIER = com.example.71b9b4f2
到
PRODUCT_BUNDLE_IDENTIFIER = com.example.14a32d1e
使用的命令 -
sed -i 's/com.example.71b94f2/com.example.14a32d1e/g' project.pbxproj
产生以下输出错误 -
sed: 1: "project.pbxproj": p 命令末尾的额外字符
我之前使用Plistbuddyshell 命令修改字段CFBUNDLEIDENTIFIER,info.plist但$(PRODUCT_BUNDLE_IDENTIFIER)在 Xcode 7 构建设置中不再更改。
我的主要目的是使用命令行或任何脚本修改 Xcode 中 BUILD SETTINGS 的 PRODUCT_BUNDLE_IDENTIFIER 字段。
iphone ×5
uitableview ×4
ios ×3
swift ×3
objective-c ×2
bash ×1
cocoa-touch ×1
ios4 ×1
logging ×1
mapkit ×1
nsarray ×1
nsdictionary ×1
nsindexpath ×1
nsinteger ×1
plist ×1
sed ×1
truncate ×1
uiimageview ×1
uilabel ×1
uiscrollview ×1
uitextview ×1
unix ×1
xcglogger ×1
xcode ×1
xcode7 ×1