質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

0回答

1701閲覧

Swift セルの既存機能 スライドして削除・編集 が端末によって動作が重い(Xibファイル)

退会済みユーザー

退会済みユーザー

総合スコア0

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2016/09/01 14:45

TableViewのセルをスライドすると編集や削除などのアクションボタンを設定できる機能があります。
イメージ説明

この度こちらを実装したのですが、
iPhoneSEではこのスライドがスラスラとできるのですが、
iPhone5(実機)だとスライドがうまくできず、動作が重い印象で、何回もスライドさせる動作をするとたまに出現する。という現象が起きています。

実装は下記の通りです。

canEditRowAtIndexPathで編集できるセルを設定

Swift

1override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 2 3 switch indexPath.section { 4 case 2: 5 //条件によってtrueかfalseを返す 6 case 3: 7 //条件によってtrueかfalseを返す 8 default: 9 return false 10 } 11 }

編集・削除のそれぞれの処理を設定

Swift

1override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { 2 3 let myShareButton: UITableViewRowAction = UITableViewRowAction(style: .Normal, title: NSLocalizedString("Edit", comment: "Edit")) { (action, index) -> Void in 4 5 let commentsController = CommentsViewController() 6 let navigationController = LGSemiModalNavViewController(rootViewController: commentsController) 7 8 let screen = UIScreen.mainScreen() 9 navigationController.view.frame = CGRectMake(0, 0, screen.bounds.size.width, screen.bounds.size.height * 0.8) 10 11 commentsController.delegate = self 12 commentsController.comment = self.comments[indexPath.row] 13 commentsController.editFlg = true 14 commentsController.event = self.event 15 commentsController.userObject = self.userObject 16 17 self.nonEditComments = [] 18 19 if self.comments.count > 0 { 20 self.nonEditComments = self.comments 21 self.nonEditComments?.removeAtIndex(indexPath.row) 22 commentsController.eventComments = self.nonEditComments!.reverse() 23 } 24 25 self.presentViewController(navigationController, animated: true) { 26 commentsController.textView.becomeFirstResponder() 27 } 28 29 } 30 myShareButton.backgroundColor = UIColor.blueColor() 31 32 let myArchiveButton: UITableViewRowAction = UITableViewRowAction(style: .Normal, title: NSLocalizedString("Delete", comment: "Delete")) { (action, index) -> Void in 33 34 let hud = MBProgressHUD.showHUDAddedTo(self.view, animated: true) 35 hud.yOffset = Float(self.view.bounds.minY) 36 37 let url = "API" 38 39 Alamofire.request(.DELETE, url, encoding: .JSON) 40 .validate() 41 .responseData { response in Utils.checkResponse(response) } 42 .responseJSON { response in 43 hud.hide(true) 44 45 switch response.result { 46 case .Success: 47 48 self.loadObjects() 49 self.tableView!.reloadData() 50 51 case .Failure(let responsError): 52 print(responsError) 53 } 54 } 55 } 56 myArchiveButton.backgroundColor = UIColor.redColor() 57 58 return [myShareButton, myArchiveButton] 59 }

変わっている点といえばセルはxibファイル作成されています。

もし同じ現象に遭遇したという方がいらっしゃいましたら是非共有いただけますと助かります!

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

fuzzball

2016/09/05 04:06

カスタムセルを使わないようにしても同様の症状が出ますか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問