views:

541

answers:

6

Hi,

Suddenly, in editing mode i can't move the cells. Before i could.

I didn't change anything.

thx

+1  A: 

Have you verified that you have made no changes in your canMoveRowAtIndexPath method?

Is your application data driven? If so, is it possible that you changed something in the data?

(I know, you said you didn't change anything. Sometimes after analysis that turns out not to be the case.)

Amagrammer
A: 

More info.

I am using custom cell, and a custom button to call to the the edit mode. And as i said before it worked.

I checked everything, even compare with a new project's settings.

Amagrammer, you say "is it possible that you changed something in the data", where do you think?

I have also put new UITableView, but without luck.

donodare
Okay. Well, post some code and we'll look at it.
Amagrammer
I don't know what to post and i can't, but i say that when i touch the three lines (the order thing in each cell), i the cell it look like i can move them, but no.I tried to put the normal uitablecell, but no luck.
donodare
+2  A: 

Ok, this question is a bit cryptically-worded but I like a puzzle! :-)

I think he's saying that when he goes into "edit" mode, the three little lines appear next to each cell, but then when he tries to "pick up" a cell it won't move.

The key thing donodare is to make sure you have implemented the following method in your tableview controller class:

// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}

This will enable rearranging.

Note that you then have to handle what happens after a user rearranges, otherwise on "letting go" of the cell it will merely pop back to where it came from.

You should do that by overriding the following method in your tableview controller class:

// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
// Custom code.  NOTE - do not call ReloadData in this method or your app will crash!
}

Hope that helps

h4xxr
Done that.Not work.
donodare
A: 

I'm having a similar issue, and this post seems to be the only related Google hit.

What I have works in the simulator just fine, but on the iPhone does not allow the cell to be reordered.

On the device, the drag handles appear (so canMoveRowAtIndexPath: is set correctly). Tap-and-holding on a drag handle causes the cell to highlight as it normally would for dragging. As soon as I begin to drag, the highlight goes away, and the cell stays put - literally it never moves at all.

Through logging, I can observe that moveRowAtIndexPath:toIndexPath: is being called when the cell is dropped.

I am limiting the available drag targets. Log reveals that targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: IS being called when running in the simulator, but IS NOT called when running on the phone. Also, the problem was occurring before this method was implemented (original design didn't require it; new design does, but it was also hoped that this method would fix the problem). It appears to be the only delegate method not firing, as all other implemented methods seem to be working just fine. The code was taken from another of my projects that works just fine on the phone. Even when this method is working properly, you can still drag the cell around, you just can only drop it in allowed locations. I cannot even begin to move the cell.

I have searched for relevant options in IB, and also the documentation for the tableview, delegates, and cells. I'm not finding anything that even hints at being useful if I wanted this behavior, so I'm at a loss for what to enable or disable. What could be a reason that a single delegate method would fire in the simulator but not on the phone?

OS 3.0/3.0.1, original iPhone, occurs on multiple devices.

Brian Slick
A: 

Follow-up with additional information...

I don't know what the specific fix (or problem) is, but I did find a correlation to something else going on, and disabled that.

By adding a bunch of log files to literally each method, I was able to see a timer firing off periodically while running in the simulator. Then when running on the device, in addition to that, I was seeing a whole crapload of messages related to the accelerometer (trying to detect shaking). I'm guessing the simulator doesn't do accelerometer, so that's why the issue didn't show up there.

The program did not require the accelerometer on that particular screen, so I put in a handler to disable it. That addressed most of the issue. The problem became significantly less frequent, but was still there. So I disabled the timer on this screen, too, and that seems to have addressed our needs.

I don't know what would have needed to happen if we actually did need the accelerometer stuff on this screen.

Brian Slick
A: 

Hi Brian,

I just had exactly the same thing happen to me - I spent ages trying to get this table loading the data just right and then when I finally did, I couldn't move any of the cells anymore. I googled and found this thread - turned out the problem was due to some accelerometer stuff I had moved from one view to all of the views - disabling it while the tableview was open fixed the problem.

I'd like to know the actual reason for the problem but I am so happy to have found a fix.

Thanks man!

Smendrick