我有一个UITableViewCell(自定义单元格),我在其中创建一些按钮和文本字段,并为按钮和文本字段分配标签.但是我无法在点击按钮上获得按钮标题和文本字段值.
在 cellForRowAtIndexPath
`[((CustomCell *) cell).btn setTag:rowTag];
[((CustomCell *) cell).textField2 setTag:rowTag+1];`
-(IBAction)submitBtnAction:(UIControl *)sender
{
for (int i=0; i<[self->_dataArray count]; i++)
{
NSIndexPath *myIP = [NSIndexPath indexPathForRow:i inSection:0];
NSLog(@"myIP.row %d",myIP.row);
UITableViewCell *cell = [tblView1 cellForRowAtIndexPath:myIP];
NSLog(@"tag %d",cell.tag);
UIButton *btn = (UIButton *)[cell.contentView viewWithTag:i];
NSLog(@"btn text %@, tag %d",btn.titleLabel.text,btn.tag);
UITextField *tf = (UITextField *)[cell.contentView viewWithTag:i+1];
NSLog(@"tf text %@, tag %d",tf.text,btn.tag);
}
}
Run Code Online (Sandbox Code Playgroud)
我收到这样的错误
-[UITableViewCellContentView titleLabel]: unrecognized selector sent to instance 0x71844e0
2013-07-17 13:48:29.998 Text[1271:c07] *** Terminating app due to uncaught …Run Code Online (Sandbox Code Playgroud) 我现在面临的问题是UIScrollView中有一个UITextField。当我单击 UITextField 时,我将显示 UIPickerView 和 UIToolBar。当 PickerView 出现时,我需要将 UITextField 向上移动。
这是我的设计

这是我的代码
func keyboardWillShow(notification: NSNotification)
{
let userInfo = notification.userInfo
if let info = userInfo
{
let animationDurationObject =
info[UIKeyboardAnimationDurationUserInfoKey] as NSValue
let keyboardEndRectObject =
info[UIKeyboardFrameEndUserInfoKey] as NSValue
var animationDuration = 0.0
var keyboardEndRect = CGRectZero
animationDurationObject.getValue(&animationDuration)
keyboardEndRectObject.getValue(&keyboardEndRect)
let window = UIApplication.sharedApplication().keyWindow
keyboardEndRect = view.convertRect(keyboardEndRect, fromView: window)
let intersectionOfKeyboardRectAndWindowRect =
CGRectIntersection(view.frame, keyboardEndRect);
UIView.animateWithDuration(animationDuration, animations: {[weak self] in
self!.scrollView.contentInset = UIEdgeInsets(top: 0,
left: 0,
bottom: intersectionOfKeyboardRectAndWindowRect.size.height,
right: 0)
self?.scrollView.scrollRectToVisible(self!.activeTextField.frame, animated: true) …Run Code Online (Sandbox Code Playgroud) NSPredicate相当于以下SQL查询的格式是什么?
SELECT*FROM tableName ORDER BY date DESC LIMIT 1
我正在尝试这个
let predicate = NSPredicate(format: "ORDER BY date LIMIT 1")
Run Code Online (Sandbox Code Playgroud)
但错误是"无法解析格式字符串"
ios ×3
swift ×2
core-data ×1
nspredicate ×1
objective-c ×1
uiscrollview ×1
uitableview ×1
uitextfield ×1
uitextview ×1