2013-01-17 124 views
6

問題後工作:的UIButton在自定義的UITableViewCell停止旋轉

我使用了包含兩個按鈕自定義UITalbeViewCell,他們在縱向做工精細。旋轉後,他們都停止響應按鈕觸摸內功能。有些人有問題,他們的按鈕旋轉後不能正確繪製。我看起來很好,因爲按鈕在旋轉後顯示在正確的位置,但它們不再響應按鈕按下。

對於我的應用程序中的這個特定視圖,我使用了UIPageController在視圖中實現多頁面,併爲嵌入在頁面滾動控制器中的視圖(將其命名爲EmbeddedView)嵌入在頁面的滾動控制器中,這裏有一個包含自定義UITableViewCell 。自定義表格視圖單元格只有一個筆尖,該文件的所有者是EmbeddedView。

在EmbeddedView

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
/*===== This is the most memory efficient way of creating table view cells =====*/ 

static NSString *CellIdentifier = @"CellIdentifier"; 

CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    [[self customTableCellNib] instantiateWithOwner:self options:nil]; 
    cell = [self customTableCell]; 
    [self setCustomTableCell:nil]; 
    } 
} 

我試了一下:

我創造了另一個筆尖文件自定義表視圖細胞和-cellForRowAtIndexPath()用它,我查了方向和動態創建通過使用不同的筆尖細胞,沒有運氣。

我在-didRotateFromInterfaceOrientation()中添加了[tableview reloadData],沒有做任何事情。

請問有人指向正確的方向嗎?任何幫助表示讚賞。

這是IB表視圖自動調整大小:

enter image description here

它看起來正確的,但按鈕不起作用

enter image description here

更新:我試着來指定不同的自動調整大小面具IB爲表格視圖,結果如下所示:

< 1>

enter image description hereenter image description here

enter image description here

< 2>

enter image description hereenter image description here

enter image description here

< 3>

enter image description here

enter image description here

< 4>

enter image description here

enter image description here

+0

只需在cellForRowAtIndexPath()方法中添加UIbutton事件,然後檢查。 –

+0

@DixitPatel:謝謝你,但它不會改變任何事情。 –

+0

按鈕是否被視覺按下?我的意思是,當你按下按鈕時,你看到按鈕變化的「向下」狀態了嗎? (默認情況下會變暗)。 – nebs

回答

4

你檢查如何上海華被調整?

檢查超級檢視是否勾選了「剪輯到邊界」。如果它沒有檢查它。這將使視圖剪輯其內容,以便看到它是否調整大小。

我想說超級視圖沒有正確調整大小,因爲觸摸事件也沒有很好地傳遞。

編輯 - 因此,這是唯一能夠讓OP達成解決方案的提示:

我通常做像意外的行爲的情況下,在縮放和這種是層次結構來改變每個視圖到不同的,可識別的,顏色。現在,您可以查看A並使用相同的背景顏色(或清除)查看B,並且您不會看到B視圖是否調整良好。祝你好運。

+0

嗨法比奧。 'clip to bounds'是指'剪輯子視圖'?因爲我無法在故事板中找到「限幅」屬性。我有類似的問題。在肖像中,tableview工作正常,但在橫向上,tableview的右半部分不能識別觸摸 - 既不是scrollview,也不是按鈕和tableviewcell的其他元素。 –

+1

@RaviSisodia:是的。您可能在正在進行觸摸事件的表格視圖之上放置了一些東西。嘗試揭示應用程序或火花檢查器的應用程序。您將能夠檢查所有視圖層次結構並查看發生了什麼。 –

+0

哦。法比奧,我忘了謝謝你。謝啦。 –