小编use*_*389的帖子

如何在单击按钮上获取UITableviewcell(自定义单元格)值

我有一个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)

objective-c uitableview ios

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

当键盘出现在 swift 中时滚动 UITextView

我现在面临的问题是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)

uiscrollview uitextfield uitextview ios swift

5
推荐指数
1
解决办法
9099
查看次数

NSPredicate中的SQL ORDER BY的等价物 - CoreData

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)

但错误是"无法解析格式字符串"

core-data nspredicate ios swift

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